Welcome to the project's Pokemon Cache API! In this project, a cache for Pokemon data is implemented and made available via a REST API. The least frequently utilised items are removed from the cache when its maximum capacity is reached.
- Store and retrieve Pokemon data by name or ID
- Delete Pokemon data by ID
- Handle concurrent requests gracefully
- Error handling and input validation
- Golang
- Docker (optional, for containerization)
-
Install dependencies:
make install-deps
-
Build the application:
make build
-
Run the application:
make run
-
Run tests:
make test -
Clean up build files:
make clean
-
Build Docker image:
make docker-build
-
Run Docker container:
make docker-run
-
Clean Docker container and image:
make docker-clean
-
URL:
/pokemon -
Method:
POST -
Request Body:
{ "id": 1, "name": "Bulbasaur", "type": "Grass/Poison", "height": 7, "weight": 69, "abilities": ["Overgrow", "Chlorophyll"] } -
Response:
201 Createdif successful
- URL:
/pokemon/id/{id} - Method:
GET - Response:
200 OKwith Pokemon data if found,404 Not Foundif not found
- URL:
/pokemon/name/{name} - Method:
GET - Response:
200 OKwith Pokemon data if found,404 Not Foundif not found
- URL:
/pokemon/id/{id} - Method:
DELETE - Response:
200 OKif successful,404 Not Foundif not found
- The default cache capacity is set to 100. You can adjust this in the
initfunction inhandlers.go. - For development and testing, you can run the application locally using the Makefile. For deployment, you might prefer using Docker.