This project intends to be used as an example of architecture with microservices and a Gateway API using Ocelot to achieve that.
Updated to .NET 6.0 and Ocelot 18.0.0.
Give a star on Ocelot Github to support the developers!
git clone https://github.com/LeaoSomogyi/poc-ocelot.git
This solution has five projects, only Poc.Ocelot.Gateway has exposed on docker network and this project knows how to redirect requests to another services.
This routes configurations can be found on ocelot.json
file.
Take a look at the diagram:
Import Poc Ocelot.postman_collection.json to Postman and follow the requests order.
Service called: Poc.Ocelot.Accounts
Only request with anonymous allowed. Used to get JWT token. If you pass the permission_claim
query param, your can change if this token returned can access Backoffice
API's or not. Possible values for this query param: Common
or Backoffice
.
Service called: Poc.Ocelot.Products
Just a simple get returning a message, but only requests authenticated can access. Note the authentication is provided by Gateway, none configuration is made on the project.
Service called: Poc.Ocelot.Payments
Just a simple get returning a message, but only requests authenticated can access. Note the authentication is provided by Gateway, none configuration is made on the project.
Service called: Poc.Ocelot.Backoffice
This project has your own authentication rule. Only tokens with permission
claim with the value Backoffice
can access this request, otherwise and status 403 is returned.
On the root folder of the solution, just run the follow command to the magic begins:
docker-compose build
Once the build was finished:
docker-compose up
To run and force build:
docker-compose up --build
- Felipe Somogyi - LeaoSomogyi
Check all contributors contributors