Skip to content

grealyve/first-fiber-gorm-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fiber Book API

This project consists of a simple book API written in Go. The API can interact with a Postgresql database and handle books using HTTP POST, GET, and DELETE methods. It runs on Docker with a connected Postgresql DB.

Installation

docker-compose up -d

go mod tidy
go run main.go

 ┌───────────────────────────────────────────────────┐
 │                   Fiber v2.48.0                   │
 │               http://127.0.0.1:3000               │
 │       (bound on host 0.0.0.0 and port 3000)       │
 │                                                   │
 │ Handlers ............. 6  Processes ........... 1 │
 │ Prefork ....... Disabled  PID ............. 00000 │
 └───────────────────────────────────────────────────┘
  1. The API will be available at http://localhost:3000 by default.
  2. The API can be accessed using the specified HTTP methods:

API Documentation

Adding a New Book - POST /api/new_books

With this request, you can add a new book to the API. The request body should be in JSON format and include the following properties:

{
  "author": "Author Name",
  "title": "Book Title",
  "publisher": "Publisher" 
}

image

Getting All Books - GET /api/books

With this request, you can retrieve all books from the API. The result will be in JSON format:

[
  {
    "id": 1,
    "author": "Author 1",
    "title": "Book 1",
    "publisher": "Publisher 1" 
  },
  {
    "id": 2,
    "author": "Author 2",
    "title": "Book 2",
    "publisher": "Publisher 2" 
  }
]

image

Getting a Specific Book - GET /api/get_book/{book_id}

With this request, you can retrieve a specific book from the API. You need to include the {book_id} parameter in the request. image

Deleting a Book - DELETE /api/delete_book/{book_id}

With this request, you can delete a specific book from the API. You need to include the {book_id} parameter in the request. image

Referrence:

https://youtu.be/1XPktts9USg

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages