A URL shortener service built with Go using the GIN framework, with storage options including MongoDB and Redis, and a frontend developed with HTML, CSS, and JavaScript.
- Shorten long URLs
- Redirect short URLs to the original URL
- Storage using either MongoDB or Redis
- Frontend using HTML, CSS, and JavaScript
- Go 1.22+
- MongoDB or Redis
git clone https://github.com/BrainAxe/url-shortener.git
cd url-shortener
go mod tidy
Create a .env file in the root directory with the following content:
MONGO_STORE_SOURCE=mongodb://localhost:27017
REDIS_STORE_SOURCE=localhost:6378
HOST_PORT=9000
go run main.go
The application will start on http://localhost:9000
.
- POST /api/shorten - Shorten a long URL
- GET /api/:shortUrl - Redirect to the original URL
The frontend, built with HTML, CSS, and JavaScript, is accessible at the root endpoint.
- Visit
http://localhost:9000
to access the frontend interface.
This project is licensed under the MIT License. See LICENSE
for more information.