This project is a URL shortener built using Go, Go Fiber, Redis, and Docker for containerization. The application allows you to shorten URLs, manage them, and store URL mappings in a Redis database.
- URL shortening and redirection
- Redis caching for fast lookups
- RESTful API to handle URL creation, retrieval, edit, and deletion
- Built with Go and Go Fiber for high performance
- Dockerized for easy deployment and development
git clone https://github.com/ThisIsNotJustin/goshort.git
DB_ADDR="db:6379" # Address for Redis container
DB_PASS="" # Password for Redis
APP_PORT=:8080 # Port to run the Go application
DOMAIN="localhost:8000" # Domain for shortening URLs
API_QUOTA=10 # Max number of URLs
docker-compose up --build
This will:
- Build the Go app
- Start Redis in a container
- Run the Go app inside a container
Test the API endpoints, I recommend using Postman.
- POST to create a shortened URL from a long URL.
{
"url": "https://www.youtube.com/watch?v=xm3YgoEiEDc",
"short": "",
"expiry": 24
}
- This will receive a response body consisting of
{
"url": "https://www.youtube.com/watch?v=xm3YgoEiEDc",
"short": "localhost:8000/exampleUrl", # random short generated when not provided
"expiry": 24, # expires in 24 hours
"rate_limit": 9, # 9 api uses remaining
"rate_limit_reset": 29 # api uses resets in 29 minutes
}