thrtn85 / library-mgmt

1 stars 0 forks source link

Library Management API Documentation

Overview

The Library Management API provides endpoints to manage a collection of books and users. It allows you to create, retrieve, update, and delete books and users. The API uses JSON for data exchange and is built using Go, Gin, and GORM with SQLite as the database.

Base URL

http://localhost:1111

Endpoints

Books

Users

Error Handling

All endpoints will return appropriate HTTP status codes and error messages in case of failures. Here are some common error responses:

Models

Book

User

Example Requests

Create a Book

curl -X POST -H "Content-Type: application/json" -d "{\"title\":\"The Go Programming Language\", \"author\":\"Alan A. A. Donovan\"}" http://localhost:1111/books

Retrieve All Books

curl http://localhost:1111/books

Retrieve a Specific Book

curl http://localhost:1111/books/1

Update a Book

curl -X PUT -H "Content-Type: application/json" -d "{\"title\":\"Updated Title\", \"author\":\"Updated Author\"}" http://localhost:1111/books/1

Delete a Book

curl -X DELETE http://localhost:1111/books/1

Create a User

curl -X POST -H "Content-Type: application/json" -d "{\"name\":\"John Doe\", \"email\":\"john@example.com\", \"password\":\"password\"}" http://localhost:1111/users

Retrieve All Users

curl http://localhost:1111/users

Retrieve a Specific User

curl http://localhost:1111/users/1

Update a User

curl -X PUT -H "Content-Type: application/json" -d "{\"name\":\"Updated Name\", \"email\":\"updated@example.com\"}" http://localhost:1111/users/1

Delete a User

curl -X DELETE http://localhost:1111/users/1