urlshortener is a simple URL shortening service implemented in Go. It provides endpoints to shorten URLs and retrieve the original URLs using the shortened versions. The service also includes Prometheus metrics for monitoring.
- Go 1.23+
- Docker & docker-compose
makefor running commands
-
Clone the repository:
git clone https://github.com/yourusername/urlshortener.git cd urlshortener -
Install dependencies:
go mod tidy
To start the application, run:
make upThe database will start listening on port 5432. The server will start on port 8000.
POST /{url}: Shorten a URL.
GET /{shortened_url}: Retrieve the original URL using the shortened version.
GET /metrics: Prometheus metrics endpoint.
Several HTTP Requests are already set in tests.http file ; the POST request store the result (the tiny url path) as parameter, enabling the call to the GET request.
PromHTTP default values are available on /metrics ; a counter realted to request parameters could be added here.