URL Shortner
URL Shortener
A simple URL shortener service built with Go and Redis that allows you to convert long URLs into short, manageable links.
Features
- Shorten long URLs to compact short codes
- Redirect from short codes to original URLs
- Redis-based storage for fast lookups
- RESTful API endpoints
- Health check endpoint
- CORS support
- Graceful shutdown
API Endpoints
POST /shorten
- Shorten a URLGET /r/{shortCode}
- Redirect to original URLGET /health
- Health checkGET /
- Hello world
Prerequisites
- Go 1.24.2+
- Redis
- Docker & Docker Compose (optional)
Quick Start
Using Docker Compose
make docker-run
Local Development
- Start Redis locally (port 6379)
- Set environment variables:
export URLSHORT_DB_ADDRESS=localhost export URLSHORT_DB_PORT=6379 export PORT=8080
- Run the application:
make run
Environment Variables
PORT
- Server portREDIS_URL
- Redis URL to parseAPP_ENV
- Application environment