A URL shortener written in Go using the Echo framework and utilizing Postgres and Redis as cache.
- Go 1.16 or higher
- Postgres
- Redis
- Clone the repository
- Set up the Postgres and Redis instances
- Copy the
.env.examplefile to.envand update the environment variables to match your environment. - Run
go buildto build the project. - Run
./url-shortenerto start the server.
- To shorten a URL, make a POST request to
/newwith a body containing the URL:
{ "url": "https://www.example.com/long-url" }
- The response will contain the shortened URL:
{ "shortUrl": "http://localhost:8080/abc123" }
- To use the shortened URL, simply visit the returned URL.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.