URL shortener design and POC
- tools pattern & config
- blog posts
- API: versioning, healthz
- Code: configfile, sqldb
To shorten a URL, send a POST request to the /shorten
endpoint with
a JSON body containing the URL to be shortened:
curl -X POST http://localhost:8080/shorten \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'
The response will contain the shortened URL:
{
"shortUrl":"http://localhost:8080/0"
}
To retrieve the original URL, send a GET request to the /{shortUrl}
endpoint:
curl http://localhost:8080/0
The response will contain redirect to the original URL.
go
1.23+ installed. You can install it by following the instructions here.mage
installed. You can install it by following the instructions here.oapi-codegen
installed. You can install it by following the instructions here.golangci-lint
installed. You can install it by following the instructions here.
To build the project, run the following command:
mage build
To run the project, use:
mage run
To execute tests, run:
mage test