Go URL Shortener API Documentation
Overview
The Go URL Shortener API allows users to create shortened URLs for easy sharing and management. It includes endpoints for user authentication, URL shortening, and user profile management, using JWT for authentication.
Base URL
http://localhost:8080
Authentication
Include the JWT token in the Authorization
header for protected endpoints.
Authorization: <your-token>
Endpoints
Auth Routes
Signup
Login
Logout
- Endpoint:
/auth/logout
- Method:
GET
URL Routes
Shorten URL
Redirect URL
- Endpoint:
/:key
- Method:
GET
User Routes
These routes require authentication.
Shorten URL (Authenticated User)
- Endpoint:
/user/short
- Method:
POST
- Request Body:
{
"url": "string"
}
Home
- Endpoint:
/user/home
- Method:
GET
- Response:
[
{
"id": 1,
"url": "https://example.com",
"key": "abc123",
"created_at": "2023-01-01T00:00:00Z",
"clicks": 100,
"user_id": 1
},
{
"id": 2,
"url": "https://anotherexample.com",
"key": "xyz789",
"created_at": "2023-01-02T00:00:00Z",
"clicks": 50,
"user_id": 1
}
]
Profile
- Endpoint:
/user/me
- Method:
GET
- Response:
{
"email": "string"
}
Delete Account
- Endpoint:
/user/delete
- Method:
DELETE
Running the Project
The server will start on port 8080.