A comprehensive REST API built with Go for managing event bookings. This project serves as a practical learning exercise for Go development while creating a reusable foundation for future event management applications.
- Event Management: Create, read, update, and delete events
- User Authentication: JWT-based authentication system
- Event Registration: Users can register for and cancel event bookings
- Authorization: Role-based access control for event operations
- RESTful Design: Clean and intuitive API endpoints
- API Versioning: Structured versioning for future compatibility
- Go 1.19 or higher
- Git
-
Clone the repository:
git clone https://github.com/yourusername/go-rest-api.git cd go-rest-api -
Install dependencies:
go mod download
-
Set up environment variables:
cp .env.example .env # Edit .env with your configuration
go run main.goThe API will start on http://localhost:8080 by default.
All endpoints are versioned using /api/v1/ prefix. This allows for future API evolution while maintaining backward compatibility.
Most endpoints require authentication. Include the JWT token in the Authorization header:
Authorization: Bearer <your-jwt-token>
| Method | Endpoint | Description | Auth Required | Notes |
|---|---|---|---|---|
GET |
/api/v1/events |
Get all available events | No | Public endpoint |
GET |
/api/v1/events/{id} |
Get event by ID | No | Public endpoint |
POST |
/api/v1/events |
Create a new event | Yes | Event creator only |
PUT |
/api/v1/events/{id} |
Update an event | Yes | Event creator only |
DELETE |
/api/v1/events/{id} |
Delete an event | Yes | Event creator only |
| Method | Endpoint | Description | Auth Required | Notes |
|---|---|---|---|---|
POST |
/api/v1/signup |
Create a new user account | No | Returns user data |
POST |
/api/v1/login |
Authenticate user | No | Returns JWT token |
POST |
/api/v1/events/{id}/register |
Register for an event | Yes | User registration |
DELETE |
/api/v1/events/{id}/register |
Cancel event registration | Yes | User cancellation |