This is a simple URL shortener service written in Go. It provides an API to create short URLs and redirect to the original URL.
- Create short URLs with custom aliases.
- Generate random short aliases if no custom alias is provided.
- Redirect to the original URL using the short alias.
- Delete short URLs.
- Rate limiting to prevent abuse.
- Caching with Redis to improve performance.
- Language: Go
- API Framework: chi
- Database: PostgreSQL
- Cache: Redis
- Logging: zap
- Containerization: Docker, Docker Compose
- Clone the repository:
git clone https://github.com/Pshimaf-Git/url-shortener.git
- Navigate to the project directory:
cd url-shortener - Start the services using Docker Compose:
docker-compose up --build
The application will be running at http://localhost:8080.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/url |
Create a new short URL. |
GET |
/api/v1/url |
Redirect to the original URL. |
DELETE |
/api/v1/url |
Delete a short URL. |
GET |
/helthy |
Health check endpoint. |
Request:
POST /api/v1/url
Content-Type: application/json
{
"url": "https://www.google.com",
"alias": "google"
}Response:
{
"status": "OK",
"alias": "google"
}Request:
GET /api/v1/url?alias=googleResponse:
Redirects to https://www.google.com.
Request:
DELETE /api/v1/url?alias=googleResponse:
{
"status": "OK",
"alias": "google"
}