This project is a simple URL shortener service built with Go (Echo). It allows users to generate short links, redirect to original URLs, view analytics, and manage shortened URLs.
- Controller, Router, Services architecture
- Echo library for building RESTful APIs.
- Create a Base Model Error and Response handling Errors, and HTTP Requests.
- Firestore usage as a NoSQL DB.
- Inject important values as environment variables.
- No Deployment, Local Running
- Integration Tests
| Method | Endpoint | Purpose |
|---|---|---|
POST |
/shorten |
Create a new short URL |
GET |
/:shortCode |
Redirect to original URL |
GET |
/stats/:shortCode |
Get stats (hits, created_at, etc.) |
DELETE |
/shorten/:shortCode |
Delete a shortened URL |
Create a new short URL.
Request Body:
{
"original_url": "https://example.com/some/very/long/url"
}Response:
{
"short_url": "http://localhost:8080/abc123"
}Redirect to the original long URL.
Example:
GET /abc123
Response:
🔁 HTTP 302 Redirect to the original URL.
Get usage statistics of a short URL.
Example:
GET /stats/abc123
Response:
{
"original_url": "https://example.com/some/very/long/url",
"short_code": "abc123",
"created_at": "2025-05-14T10:00:00Z",
"clicks": 42
}Delete a shortened URL.
Example:
DELETE /shorten/abc123
Response:
{
"message": "Short URL deleted successfully"
}