github.com/gudimz/urlShortener@v0.0.0-20230129195305-c8ee33059a67/README.md (about)

     1  # Short url generator
     2  
     3  ![Lines of code](https://img.shields.io/tokei/lines/github/gudimz/urlshortener)
     4  ![License](https://img.shields.io/github/license/gudimz/urlShortener)
     5  ![Go version](https://img.shields.io/github/go-mod/go-version/gudimz/urlshortener)
     6  ![Last commit](https://img.shields.io/github/last-commit/gudimz/urlshortener)
     7  
     8  This is simple project for understanding how work with postgresql, docker in golang. It generates for an url a short url or uses 
     9  the custom short url sent in the request.
    10  ## REST API
    11  ### Method POST
    12  This method creates new short url.
    13  - path: `api/v1/create/`
    14  - body:
    15  ```json
    16  {
    17      "url":"https://example.com",
    18      "short_url":"example"
    19  }
    20  ```
    21  if you need to generate a short url - sent only the url
    22  - return body:
    23  ```json
    24  {
    25    "message": "http://localhost:8080/example"
    26  }
    27  ```
    28  - code: `200`
    29  ### Method GET
    30  This method redirects to the original url or returns all short url information.
    31  - **redirect:**
    32    - path: `short_url`
    33    - code: `301`
    34  - **short url info:**
    35      - path: `api/v1/short_url`
    36      - return body:
    37  ```json
    38  {
    39    "short_url": "example",
    40    "origin_url": "https://example.com",
    41    "visits": 1,
    42    "date_created": "2023-01-29T17:33:42.901111Z",
    43    "date_updated": "2023-01-29T19:22:15.431546Z"
    44  }
    45  ```
    46  - code: `200`
    47  ### Method DELETE
    48  This method delete short url info from database.
    49  - path: `api/v1/delete/short_url`
    50  - code: `204`
    51  ## Usage
    52  ```shell
    53  #build docker image
    54  make build
    55  
    56  #run the application
    57  make run
    58  
    59  #test application into container
    60  make test
    61  
    62  #stop the application
    63  make stop
    64  ```