The minimal APIs project
After having the models and the repository contract in place, we can move over to creating the project hosting the REST API.
Here, we’ll use ASP.NET Core with minimal APIs to create a REST API, and store games and moves in an in-memory repository. To create the running games API, we need to do the following:
- Create a Web API project.
- Implement the games repository.
- Create a games factory.
- Create data transfer objects.
- Create endpoints to run the game via HTTP requests.
- Configure the JSON serializer.
- Add endpoint filters.
To better understand how the different classes interact in creating the game and setting a move, the flow of the functionality we need to implement is shown in the next two figures.
Figure 2.2 shows the sequence when a new game is created. On invoking the API call, GamesService
is invoked to start the game. This service class uses GamesFactory
to create a new game based on the parameters...