Why shorten the URL?
- Easy URL memorization
- Less characters to use in social media
- Decoupled front-end (build your own front-end)
- Decoupled back-end (open API)
- Easy to customize
- Dockerized
Each URL sent to be shortened will be cached for 30 minutes. as well saved in database. Any request that was erased from redis but still in database will be bounded again to redis.
The back-end API only respond with a simple json
that contains the code
to be used after your domain, example:
curl -X POST http://localhost:5000/short \
-d '{
"url": "http://an-long-url.com.br/page/"
}'
{"url":"F9WL"}
docker-compose up -d
By default the port 5000
is used, feel free to changed it, but don't forget to change on docker compose file as well.
-
GET
/
- show the main html page with a form -
GET
/{id}
- redirect the user for the given encoded key given if exist on redis or in database -
GET
/info/{id}
- return ajson
with all information about the givenid
- example:
{ "url":"http://9gag.com", "encoded":"G", "clicks":3, "created_at":"2018-06-12T19:25:18.786986Z" }
- example:
-
POST
/short
- return ajson
with the given key for a url encoded- example:
{ "url": "9ZYOP" }
- example: