This is a simple movie API implemented in Go using the Gorilla Mux router. It allows you to perform basic operations on movies.
- Endpoint:
/movies - Method: GET
- Description: Retrieve a list of all movies.
- Response: Returns a JSON array containing all movies.
- Endpoint:
/movies/{id} - Method: GET
- Description: Retrieve a specific movie by its ID.
- Response: Returns a JSON object representing the movie if found, or a 404 Not Found response if no movie with the specified ID exists.
- Endpoint:
/movies - Method: POST
- Description: Create a new movie.
- Request Body: Expects a JSON object representing the movie to be created. The
idfield will be automatically generated. - Response: Returns a JSON object representing the created movie.
- Endpoint:
/movies/{id} - Method: DELETE
- Description: Delete a movie by its ID.
- Response: If a movie with the specified ID is found and successfully deleted, returns a 200 OK response. If no movie with the specified ID exists, returns a JSON array containing all movies.
A movie object has the following properties:
id(string): The unique identifier of the movie.title(string): The title of the movie.genre(string): The genre of the movie.director(object): Information about the director of the movie, including thenameandageproperties.
- Make sure you have Go installed on your machine.
- Clone this repository.
- Navigate to the project directory.
- Build and run the project with the following command:
go run main.go