Simple url-shortener written in Golang with Redis database
docker-compose build
Assume that Redis already running on port 6379
make test
docker-compose up
GET /info/{encoded_url}
curl -L -X GET 'http://localhost:8080/WuYbydedVqi'
{
"id":"WuYbydedVqi",
"url":"https://www.alexedwards.net/blog/working-with-redis",
"visits":2,
"expire":"4.10.2022 17:18:0",
"once":false
}
POST /encode
Params (json):
- url [string]
- expire - UTC date in format d.m.y h:m:s [string]
- once - allows only one redirect [boolean]
curl -L -X POST 'localhost:8080/encode' -H 'Content-Type: application/json' --data-raw '{
"url": "https://www.alexedwards.net/blog/working-with-redis",
"expire": "4.10.2022 17:18:00",
"once": false
}'
{
"status":"success",
"url":"http://localhost:8080/YbnuLt4L5Eu"
}
GET /{encoded_url}
curl -L -X GET http://localhost:8080/OTv0FdGU8Ng
DELETE /{encoded_url}
curl -L -X DELETE http://localhost:8080/OTv0FdGU8Ng