Skip to content

API developed with Go, Gin Gonic, Gorm, PostgreSQL and Docker.

Notifications You must be signed in to change notification settings

lucasfrancaid/go-api

Repository files navigation

Go Api

My first API developed in Go, built with Gin and Gorm.

Requirements

  • Go 1.16
  • Docker & Docker Compose

Setup

Run below code to setup go-api with docker:

docker-compose --build up
# or
make run_docker

If you want use go-api without docker:

make run_postgres # you need a postgres database
make run

API Requests

Run in Insomnia}

Authors

[POST] Create Author --> http://localhost:8080/v1/authors
[GET] Get All Authors --> http://localhost:8080/v1/authors
[GET] Get Author --> http://localhost:8080/v1/authors/1
[GET] Get Author Books --> http://localhost:8080/v1/authors/1/books
[PUT] Update Author --> http://localhost:8080/v1/books/1
[DELETE] Delete Authors --> http://localhost:8080/v1/authors/1

// [post, put] request schema
{
	"name": "Robert C. Martin (Uncle Bob)",
	"site": "https://github.com/unclebob"
}

Books

[POST] Create Book --> http://localhost:8080/v1/books
[GET] Get All Books --> http://localhost:8080/v1/books
[GET] Get Book --> http://localhost:8080/v1/books/1
[PUT] Update Book --> http://localhost:8080/v1/books/1
[DELETE] Delete Books --> http://localhost:8080/v1/books/1

// [post, put] request schema
{
	"title": "Clean Coder",
	"author_id": 1,
	"price": 19.89,
	"published": "2018-11-22T15:04:00Z"
}