Skip to content

aabdullahgungor/mybookcase

Repository files navigation

Go RESTful API with Gin Web Framework & MySQL

This is an example golang backend application using MySQL database with clean architecture.

Features

  • Go Web Framework (gin-gonic)
  • Swagger (swaggo)
  • CRUD operations
  • JWT for authentication
  • MySQL Driver: GORM

Getting Started

# download the project
git clone https://github.com/aabdullahgungor/mybookcase.git

cd mybookcase

Run the Project

go run main.go

Access API using

http://localhost:9090/api/v1

Database Diagram

Diagram

Sample of Endpoints

  • GET localhost:9090/api/v1/books
  • GET localhost:9090/api/v1/books/:id
  • POST localhost:9090/api/v1/books
  • PUT localhost:9090/api/v1/books
  • DELETE localhost:9090/api/v1/books/:id
  • ........

Sample API Requests and Responses

POST localhost:9090/api/v1/authors

localhost:9090/api/v1/authors

request body:

{
        "id": 8,
        "name": "Yazar8"
  }

response body:

{
    "author_id": 8,
    "message": "Author has been created"
}

POST localhost:9090/api/v1/books

localhost:9090/api/v1/books

request body:

 {
        "id": 8,
        "name": "Kitap8",
        "description": "Aciklama8",
        "published_date": "2020-08-08T00:00:00Z",
        "edition": 8,
        "total_pages": 800,
        "language": "Turkce",
        "isbn": "12345678",
        "image_url": "imageUrl8",
        "author_id": 6,
        "reader_id": 1
    }

response body:

{
    "book_id": 8,
    "message": "Book has been created"
}

POST localhost:9090/api/v1/categories

localhost:9090/api/v1/categories

request body:

 {
        "id": 7,
        "category_name": "Kategori7"
    }

response body:

{
    "category_id": 7,
    "message": "Category has been created"
}

POST localhost:9090/api/v1/publishers

localhost:9090/api/v1/publishers

request body:

  {
        "id": 7,
        "publisher_name": "Yayinevi7"
    }

response body:

{
    "message": "Publisher has been created",
    "publisher_id": 7
}

POST localhost:9090/api/v1/readers

localhost:9090/api/v1/readers

request body:

{
        "id": 3,
        "name": "reader3",
        "email": "reader3@hotmail.com",
        "password": "123456"
    }

response body:

{
    "email": "reader3@hotmail.com",
    "message": "Reader has been created",
    "name": "reader3",
    "reader_id": 3
}

Open API Doc Preview

http://localhost:9090/api/v1/swagger/index.html

Swagger

About

Go RESTful API with Gin Web Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages