This project is a simple Book Management API built using the Go programming language and the Gin web framework. It provides endpoints to perform basic CRUD operations on a collection of books, such as retrieving book details, adding new books, and updating book quantities for checkout and return operations.
- Retrieve a list of all books.
- Retrieve a book by its ID.
- Add a new book to the collection.
- Checkout a book (reduce quantity).
- Return a book (increase quantity).
Method | Endpoint | Description |
---|---|---|
GET | /books |
Get a list of all books. |
GET | /books/:id |
Get details of a specific book. |
POST | /books |
Add a new book to the collection. |
PATCH | /checkout |
Checkout a book by ID (decrease quantity). |
PATCH | /return |
Return a book by ID (increase quantity). |
- Programming Language: Go
- Web Framework: Gin
- Install Go
- Install dependencies:
go mod init books-api go get -u github.com/gin-gonic/gin
- Clone the repository:
git clone https://github.com/your-repo/book-management-api.git
- Navigate to the project directory:
cd book-management-api
- Run the application:
go run main.go
- The API will be available at
http://localhost:8080
{
"id": "4",
"title": "Hamlet",
"author": "William Shakespeare",
"quantity": 2
}
This project has been tested and developed on:
- Windows
- Linux
- macOS