Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 1.83 KB

File metadata and controls

57 lines (42 loc) · 1.83 KB

Go REST API

A lightweight and clean REST API built with Go and the Gin framework. This project demonstrates core backend engineering patterns, including JWT-based authentication, custom middleware, and SQLite database integration. It serves as an excellent reference for developers building scalable RESTful services in Go.

Features

  • RESTful API Design: Follows standard HTTP methods and resource-based routing.
  • Authentication: JWT (JSON Web Token) based authentication for secure endpoints.
  • Middleware: Custom request logging and authentication validation.
  • Database Integration: SQLite integration with automated table creation on startup.
  • Models & Logic: Clean separation of data models and business logic.
  • API Testing: Pre-configured .http files for rapid testing via IDE.

Getting Started

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/janfess/go-REST-API.git
    cd go-REST-API
  2. Install dependencies:

    go mod download
  3. Run the application:

    go run .

    The server will start on http://localhost:8080.

API Endpoints

Public Endpoints

  • POST /signup - Register a new user
  • POST /login - Authenticate a user and receive a JWT token
  • GET /events - List all events
  • GET /events/:id - Get details of a specific event

Protected Endpoints (Requires JWT)

  • POST /events - Create a new event
  • PUT /events/:id - Update an existing event
  • DELETE /events/:id - Delete an event
  • POST /events/:id/register - Register for an event
  • DELETE /events/:id/register - Cancel registration for an event

License

Distributed under the MIT License. See LICENSE for more information.