A simple library API created with Go, where we can revise all available books in the library, check in and check out books, and get books by ID. This project uses Gin, a high performance and simple web framework that is used to create APIs with Go.
- Clone the repository with:
git clone "https://github.com/WilhenAlbertoHM/Library-API-Go.git"- Run the following command to start the server:
go run main.go- On another terminal, use the following commands to interact with the API: To check all available books:
# Get all books
curl -X GET http://localhost:8080/booksTo add a book:
# Add a book
curl localhost:8080/books --include --header "Content-Type: application/json" -d @body.json --request "POST"To check out a book:
# Check out a book
curl -X PUT http://localhost:8080/books/checkout/1To check in a book:
# Check in a book
curl -X PUT http://localhost:8080/books/checkin/2To get a book by ID:
# Get a book by ID
curl -X GET http://localhost:8080/books/3This project was done with the intent to learn more about creating APIs with Go. This project was brought by Tech With Tim, and all the code was shared by him.