golang-basic-rest-api

module
v0.0.0-...-568e02e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2024 License: GPL-3.0

README

Golang Basic REST API

This project is a basic REST API built with Golang.

Features

  • Basic CRUD operations
  • RESTful endpoints
  • JSON responses
  • Database & Migration system in SQLite

Requirements

  • Go 1.16 or higher

Installation

  1. Clone the repository:
    git clone https://github.com/sherwin-77/golang-basic-rest-api.git
    
  2. Navigate to the project directory:
    cd golang-basic-rest-api
    
  3. Install dependencies:
    go mod tidy
    

Migrating

All migrate command available in cmd/migrate

Creating Migration
go run cmd/migrate create create_any_tables
Apply Migration
go run cmd/migrate up
Rollback Migration
go run cmd/migrate down

DB path can be customized in config.json

Usage

Make sure you already run migration

go run cmd/migrate up
  1. Run the server:
    go run cmd/server
    
  2. The API will be available at http://localhost:8080.

Endpoints

  • GET /todos - Retrieve all todos
  • GET /todos/{id} - Retrieve a specific todo by ID
  • POST /todos - Create a new todo
  • PATCH /todos/{id} - Update an existing todo by ID
  • DELETE /todos/{id} - Delete an todo by ID

Building

SoonTM

Directories

Path Synopsis
cmd
migrate command
server command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL