Sure, here's a basic README.md file based on the provided code:
The Movies API is a Go application that interacts with the Star Wars API (SWAPI) to fetch movie data and store it in a Redis cache. It also provides endpoints to add comments to movies and fetch movie details along with associated comments.
- Ping: Check if the server is alive and listening.
- AddComment: Add comments to movies.
- FetchMovies: Fetch a list of movies along with associated comments.
- FetchMovie: Fetch details of a single movie along with associated comments.
- FetchMovieCharacters: Fetch characters for a specific movie.
- Go installed on your local machine
- Redis server running locally or accessible via network
- PostgreSQL database set up (if using the comment feature)
-
Clone the repository:
https://github.com/ADEMOLA200/go-movie-api.git
-
Install dependencies:
go mod tidy
-
Set up environment variables:
- Ensure that the following environment variables are set:
REDIS_HOST
: Hostname or IP address of the Redis serverREDIS_PORT
: Port on which Redis is runningPOSTGRES_DSN
: Data Source Name (DSN) for connecting to the PostgreSQL database (if using the comment feature)
- Ensure that the following environment variables are set:
-
Run the application:
go run main.go
-
Ping:
- Endpoint:
/ping
- Method:
GET
- Description: Check if the server is alive and listening.
- Endpoint:
-
AddComment:
- Endpoint:
/movies/{movie_id}/comments
- Method:
POST
- Description: Add a comment to a specific movie.
- Endpoint:
-
FetchMovies:
- Endpoint:
/movies
- Method:
GET
- Description: Fetch a list of movies along with associated comments.
- Endpoint:
-
FetchMovie:
- Endpoint:
/movies/{movie_id}
- Method:
GET
- Description: Fetch details of a single movie along with associated comments.
- Endpoint:
-
FetchMovieCharacters:
- Endpoint:
/movies/{movie_id}/characters
- Method:
GET
- Description: Fetch characters for a specific movie.
- Endpoint:
Contributions are welcome! Please feel free to fork the repository and submit pull requests to suggest improvements or new features.
This project is licensed under the MIT License - see the LICENSE file for details.