This is a simple CRUD (Create, Read, Update, Delete) API implemented in Go using the Gorilla Mux router.
- 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.
-
Clone the repository:
git clone https://github.com/Yash-sudo-web/GolangCRUD
-
Navigate to the project directory:
cd GolangCRUD
-
Build and run the application:
go build . && ./crud
- GET /movies: Retrieve a list of all movies.
- GET /movies/{id}: Retrieve a single movie by its ID.
- POST /movies: Create a new movie.
- PUT /movies/{id}: Update an existing movie by its ID.
- DELETE /movies/{id}: Delete a movie by its ID.
You can use tools like cURL or Postman to interact with the API endpoints. Here are some examples:
-
Get all movies:
curl http://localhost:8000/movies
-
Get a movie by ID:
curl http://localhost:8000/movies/1
-
Create a new movie:
curl -X POST -H "Content-Type: application/json" -d '{"isbn":"123456","title":"New Movie","director":{"firstname":"Jane","lastname":"Doe"}}' http://localhost:8000/movies
-
Update an existing movie:
curl -X PUT -H "Content-Type: application/json" -d '{"isbn":"123456","title":"Updated Movie","director":{"firstname":"Jane","lastname":"Doe"}}' http://localhost:8000/movies/1
-
Delete a movie by ID:
curl -X DELETE http://localhost:8000/movies/1
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.