Golang API Boilerplate

Golang API boilerplate using:

  • Gorm v2
  • S.O.L.I.D principles
  • Service pattern
  • Gorilla Mux
  • Govalidator
  • Postgres

It’s a simple api. The database entities are:

  • User
  • Book
  • Borrowed Book

As one user can borrow many books

Routes

Method Endpoint Body Query Description
GET /user none none Lists all users
POST /user { email:string, password: string, name: string, picture: string } none Creates a user
POST /book { name:string, author: string, release_year: number } none Creates a book
GET /book/{userId}/borrowed none none Lists all books borrowed by user with given ID
POST /book/{bookId}/borrow { user_id: string } none Makes user borrow book

GitHub

View Github