GoSQL is a simple CRUD application built in Go using Gorilla Mux and GORM, which provides a RESTful API for managing books.
- Retrieve a list of movies
- Retrieve a single movie by ID
- Create a new movie
- Update an existing movie
- Delete a movie by ID
Make sure you have Go installed on your machine. You can download and install it from here.
- Gorilla Mux: A powerful HTTP router and URL matcher for building Go web servers with routing capabilities.
- GORM: An Object Relational Mapping library for Go. It provides a simple and efficient way to work with SQL databases.
-
Clone the repository:
git clone https://github.com/Yash-sudo-web/gosql_bookmanagement.git
-
Navigate to the project directory:
cd cmd/main
-
Build and run the application:
go build . && ./main
- GET /book/{id}: Get details of a book by ID.
- GET /book/: Get details of all books.
- POST /book/: Create a new book.
- PUT /book/{id}: Update details of a book by ID.
- DELETE /book/{id}: Delete a book by ID.
You can use tools like cURL or Postman to interact with the API endpoints. Here are some examples:
-
Get all books:
curl http://localhost:8000/book/
-
Get a book by ID:
curl http://localhost:8000/book/1
-
Create a new book:
curl -X POST -H "Content-Type: application/json" -d '{ "name": "The Great Gatsby", "author": "F. Scott Fitzgerald", "publication": "Scribner" }' http://localhost:8000/book/
-
Update an existing movie:
curl -X PUT -H "Content-Type: application/json" -d '{ "name": "The Great Gatsby", "author": "F. Scott Fitzgerald", "publication": "Scribner" }' http://localhost:8000/book/1
-
Delete a movie by ID:
curl -X DELETE http://localhost:8000/book/1
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.