github.com/jackc/pgx/v5@v5.5.5/examples/url_shortener/README.md (about)

     1  # Description
     2  
     3  This is a sample REST URL shortener service implemented using pgx as the connector to a PostgreSQL data store.
     4  
     5  # Usage
     6  
     7  Create a PostgreSQL database and run structure.sql into it to create the necessary data schema.
     8  
     9  Configure the database connection with `DATABASE_URL` or standard PostgreSQL (`PG*`) environment variables or
    10  
    11  Run main.go:
    12  
    13  ```
    14  go run main.go
    15  ```
    16  
    17  ## Create or Update a Shortened URL
    18  
    19  ```
    20  curl -X PUT -d 'http://www.google.com' http://localhost:8080/google
    21  ```
    22  
    23  ## Get a Shortened URL
    24  
    25  ```
    26  curl http://localhost:8080/google
    27  ```
    28  
    29  ## Delete a Shortened URL
    30  
    31  ```
    32  curl -X DELETE http://localhost:8080/google
    33  ```