module
Version:
v0.0.0-...-568e02e
Opens a new window with list of versions in this module.
Published: Oct 4, 2024
License: GPL-3.0
Opens a new window with license information.
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
Installation
- Clone the repository:
git clone https://github.com/sherwin-77/golang-basic-rest-api.git
- Navigate to the project directory:
cd golang-basic-rest-api
- 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
- Run the server:
go run cmd/server
- 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
¶
cmd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Click to show internal directories.
Click to hide internal directories.