The Go-Server project is a simple web application built with Go, utilizing the Gin framework for routing, and PostgreSQL as the database. This project demonstrates the core principles of building and deploying a RESTful API with JWT authentication, focusing on managing events and user registration.
- User Authentication: Secure login and signup functionality with JWT tokens.
- Event Management: Create, retrieve, update, and delete events.
- User Event Registration: Register and unregister for events.
- Dockerized Deployment: Easy deployment using Docker and Docker Compose.
- Programming Language: Go
- Framework: Gin
- Database: PostgreSQL
- Authentication: JWT (JSON Web Tokens)
- Containerization: Docker
- GET /events
- Fetch all events.
- GET /events/:id
- Fetch a specific event by ID.
- POST /events
- Create a new event (requires authentication).
- PUT /events/:id
- Update an event by ID (requires authentication).
- DELETE /events/:id
- Delete an event by ID (requires authentication).
- POST /register
- Register for an event (requires authentication).
- POST /unregister
- Unregister from an event (requires authentication).
- POST /signup
- Create a new user account.
- POST /login
- Authenticate and log in to receive a JWT token.
- Docker installed on your machine
- Docker Compose installed
-
Clone the Repository
git clone https://github.com/tejasvi541/Go-Server.git cd Go-Server
-
Build and Run the Docker Containers
docker-compose up --build
-
Access the Application
The server will run on
http://localhost:8080
.- Use tools like Postman or curl to interact with the endpoints.
- Ensure to include the JWT token in the
Authorization
header for routes that require authentication.
The Docker image for this project can be found on Docker Hub.
You can configure the following environment variables in the .env
file:
DB_HOST
: Database host (default islocalhost
)DB_PORT
: Database port (default is5432
)DB_USER
: Database username (default ispostgres
)DB_PASSWORD
: Database passwordDB_NAME
: Database name (default isevents
)JWT_SECRET
: Secret key for JWT tokens
Contributions are welcome! Please fork the repository and create a pull request to contribute to this project.
This project is licensed under the MIT License.
Happy coding! 🎉