Skip to content

rupa4ok/rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c7ca15b · Feb 18, 2021

History

9 Commits
Feb 18, 2021
Feb 17, 2021
Feb 16, 2021
Feb 18, 2021
Feb 16, 2021
Feb 17, 2021
Feb 18, 2021
Feb 18, 2021
Feb 17, 2021
Feb 17, 2021
Feb 17, 2021

Repository files navigation

Rest Api go gin + gorm

It is a just simple RESTful API with Go using:

  1. Gin Framework
  2. Gorm

This Gin GORM API Boilerplate with MVC paradigm.

Installation & Run

Setting DB in main.go

make init

After build: localhost:8080

Db connection: .env

Default server port in dockerfile: ENV PORT 8080, external port in docker-compose.yml.

Structure

├── docker
│   └── app 
│       └── Dockerfile
├── src
│    ├── Models
│    │   ├── Book.go // Book models
│    |	 ├── Scheme.go // Book struct and tabel
│    ├── Config
│    │   └── Database.go // Global DB
│    ├── Controllers
│    │   └── Book.go // Book Controller
│    ├── ApiHelpers
│    │   └── Response.go // response function
│    └── Routers
│        └── Routers.go // Routers
└── main.go

API

/book

  • GET : Get all book
  • POST : Create a new book

/book/:id

  • GET : Get a book
  • PUT : Update a book
  • DELETE : Delete a book

#Post Params

{
	"author": "Op Super John Doe Bilw",
	"name": "Implementation Golang",
	"category": "Knowledge"
}

About

Rest api with gin and gorm example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published