Skip to content

kmulqueen/go-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go REST API - Event Booking System

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.

Table of Contents

Features

  • 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

Getting Started

Prerequisites

  • Go 1.19 or higher
  • Git

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/go-rest-api.git
    cd go-rest-api
  2. Install dependencies:

    go mod download
  3. Set up environment variables:

    cp .env.example .env
    # Edit .env with your configuration

Running the API

go run main.go

The API will start on http://localhost:8080 by default.

API Documentation

All endpoints are versioned using /api/v1/ prefix. This allows for future API evolution while maintaining backward compatibility.

Authentication

Most endpoints require authentication. Include the JWT token in the Authorization header:

Authorization: Bearer <your-jwt-token>

Events Endpoints

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

User Endpoints

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

About

REST API built with Go. JWT-Authentication and protected routes. RBAC for event operations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages