A modern, fast, and reliable URL shortening service built with Go and Redis. This service allows you to create shortened URLs with optional custom aliases, perfect for sharing links in a more manageable way.
- Create shortened URLs instantly
- Custom alias support
- Fast redirects using Redis
- URL validation
- Clean and simple web interface
- Docker support
- Detailed logging
- Go (Gin Web Framework)
- Redis
- Docker & Docker Compose
- HTML/Templates
- Go 1.x
- Docker and Docker Compose
- Redis (if running locally)
-
Clone the repository:
git clone https://github.com/ayush5588/shorturl.git cd shorturl
-
Run with Docker Compose:
docker-compose up
This will start both the web server and Redis container.
-
Access the application at
http://localhost:8080
REDIS_HOST
: Redis host address (default: "redis")REDIS_PORT
: Redis port (default: 6379)DOMAIN_NAME
: Domain name for shortened URLs (default: "http://localhost:8080/")
GET /
: Home page with URL shortening interfacePOST /short
: Create a shortened URL- Parameters:
originalURL
: The URL to shorten (required)alias
: Custom alias (optional)
- Parameters:
GET /:id
: Redirect to the original URLGET /healthz
: Health check endpoint
- Original URLs must be valid and include scheme (http/https)
- Custom aliases:
- Must be unique
- Maximum length: 15 characters
- Cannot contain special characters: !@#$%^&*()+={}[]|`/?.>,<:;'
- Optional (system will generate a unique ID if not provided)
To run locally without Docker:
- Start Redis server
- Set environment variables
- Run the application:
go run main.go
Run the tests:
go test ./...
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.