What if the description of each Pokemon were to be written using Shakespeare's style?
This is a REST API that, given a Pokemon name, returns its Shakespearean description.
Signature: GET endpoint: /pokemon/<pokemon name>/
Example: http://localhost:5000/pokemon/charizard/
Output:
{
"name": "charizard",
"description": "Charizard flies 'round the sky in search of powerful opponents.
't breathes fire of such most wondrous heat yond 't melts aught. However,
't nev'r turns its fiery breath on any opponent weaker than itself."
}
Download the Linux image from Docker Hub and run it:
docker pull lmazzanti/shakespeare-pokemon
docker run -d -p 5000:80 --name shakespeare-pokemon lmazzanti/shakespeare-pokemon
If you have an authentication token from Fun Translations you can pass it as:
docker run -d -p 5000:80 -e "API:Shakespeare:AuthenticationToken=xxxx" --name shakespeare-pokemon shakespeare-pokemon
Go to http://localhost:5000 in a browser to test the app.
Go to the Swagger API link to read the examples.
See Docker Hub repository for more details.
See Docker run command form more details on how to run it.
Here the steps to build and run locally the program.
Download the source manually or clone the Git repository:
git clone https://github.com/lucamazzanti/shakespeare-pokemon
Navigate to the project folder at \ShakespearePokemon.API.
Run the following command to build and run the app locally:
dotnet run
Go to http://localhost:5000 in a browser to test the app.
Press Ctrl+C at the command prompt to stop the app.
In the Docker client, switch to Linux containers.
Navigate to the project folder at \ShakespearePokemon.API.
Run the following commands to build and run the app in Docker:
docker build -f Dockerfile -t shakespeare-pokemon ..
docker run -it --rm -p 5000:80 --name shakespeare-pokemon shakespeare-pokemon
The build command arguments:
- Name the image shakespeare-pokemon.
- Run the Dockerfile working from the parent folder (the double period at the end).
The run command arguments:
- Allocate a pseudo-TTY
- Automatically remove the container when it exits.
- Map port 5000 on the local machine to port 80 in the container.
- Name the container shakespeare-pokemon.
- Specify the shakespeare-pokemon image.
If you have an authentication token from Fun Translations you can pass it as:
docker run -it --rm -p 5000:80 -e "API:Shakespeare:AuthenticationToken=xxxx" --name shakespeare-pokemon shakespeare-pokemon
Go to http://localhost:5000 in a browser to test the app.
This is a case study of a RESTful API made in ASP NET Core.
It consumes 2 external API and produces a new result.
- The pokemon API asks caching as requirement.
- The translation API has an heavy rate limiting of 5 calls\hour without an authentication token.
The project structure choosen for that tiny example avoid over splitting into projects:
- A single Web Api 5.0 project, layers are divided in folders.
- A single NUnit test project holding all the categories: unit, integration, functional tests.
The project can be run in a linux docker container, hosted on a web server or self-hosted.
The project was developed using the github management lifecycle, see here for tasks and more considerations.
Github actions runs the CI/CD.