My first API developed in Go, built with Gin and Gorm.
- Go 1.16
- Docker & Docker Compose
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
[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"
}
[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"
}