This repo contains Golang RestApi code for Events registration, user creation, events deletion and updation
A Go-powered "Event Booking" REST API that allows users to browse, create, update, and delete events, as well as manage user registrations and authentication.
GET /events
GET /events/{id}
POST /events
PUT /events/{id}
DELETE /events/{id}
POST /signup
POST /login
POST /events/{id}/register
DELETE /events/{id}/register
The API uses JSON Web Tokens (JWT) for authentication. Users must include the token in the Authorization header of requests to protected endpoints.
Example:
Authorization: Bearer <your-token>
git clone https://github.com/your-username/event-booking-api.git
cd event-booking-api
Gin (HTTP web framework written in Go)
go get -u github.com/gin-gonic/gin
SQLite3 driver for Go
go get github.com/mattn/go-sqlite3
bcrypt for password hashing
go get -u golang.org/x/crypto
JSON Web Tokens for Go
go get -u github.com/golang-jwt/jwt/v5
Set up environment variables (e.g., database configuration, JWT secret).
go run main.go
Once the API is running, you can interact with it using tools like curl, Postman, or any HTTP client.
Create an Event:
curl -X POST -H "Authorization: Bearer <your-token>" -d '{"name": "Event Name", "date": "2024-01-01", "location": "Event Location"}' http://localhost:8080/events
Register for an Event:
curl -X POST -H "Authorization: Bearer <your-token>" http://localhost:8080/events/{id}/register