This is simple project for understanding how work with postgresql, docker in golang. It generates for an url a short url or uses the custom short url sent in the request.
This method creates new short url.
- path:
api/v1/create/
- body:
{
"url":"https://example.com",
"short_url":"example"
}
if you need to generate a short url - sent only the url
- return body:
{
"message": "http://localhost:8080/example"
}
- code:
200
This method redirects to the original url or returns all short url information.
- redirect:
- path:
short_url
- code:
301
- path:
- short url info:
- path:
api/v1/short_url
- return body:
- path:
{
"short_url": "example",
"origin_url": "https://example.com",
"visits": 1,
"date_created": "2023-01-29T17:33:42.901111Z",
"date_updated": "2023-01-29T19:22:15.431546Z"
}
- code:
200
This method delete short url info from database.
- path:
api/v1/delete/short_url
- code:
204
#build docker image
make build
#run the application
make run
#test application into container
make test
#stop the application
make stop