A service that provides functionality such as Tiny URL
> go build
> go test .\test
use this api to create a unique shortened url
[JSON] request
field | type | description |
---|---|---|
url | string | destination url |
sample request
curl -X POST http://localhost:8888/create -d "{\"url\":\"https://www.google.com\"}'
[JSON] reponse
field | type | description |
---|---|---|
url | string | shortened url |
sample response
{
"url": "localhost:8888/d6fe7c"
}
visiting http://localhost:8888/d6fe7c in browser will be redirect to original url: https://www.google.com
use this api to get stats of a specific id
[JSON] request
no
sample request
curl -X GET http://localhost:8888/stats/d6fe7c
[JSON] reponse
field | type | description |
---|---|---|
id | string | unique 6 characters alphanumeric |
destination | string | destination url |
redirect_count | int | redirect count since created |
created_at | int64 | creation time in unix milliseconds |
sample response
{
"id": "d6fe7c",
"destination": "https://www.google.com",
"redirect_count": 0,
"created_at": 1655530287098
}
use this api to get ids' stats
[JSON] request
no
sample request
curl -X GET http://localhost:8888/stats
[JSON] reponse
field | type | description |
---|---|---|
id | string | unique 6 characters alphanumeric |
destination | string | destination url |
redirect_count | int | redirect count since created |
created_at | int64 | creation time in unix milliseconds |
sample response
[
{
"id": "d6fe7c",
"destination": "https://www.google.com",
"redirect_count": 0,
"created_at": 1655530287098
}
]