Search code examples
c#microservicesapi-gatewayocelot

Ocelot API Gateway - Best url template to assign microservices?


We have a number of microservices in our company. We also use the Api Gateway pattern to route these microservices, which in fact we used Ocelot for this. What is the best Url format for applying to these Microservices?

The important thing is that we use Rest architecture for our service

For example, I have these templates right now:

api.example.com/microservice1/{controller}

example.com/api/microservice1/{controller}

what is your opinion?


Solution

  • IMHO,

    This pattern

    example.com/api/microservice1/{controller}
    

    is good if you intend to implement a separation between your APIs and WFE (Web Frontend) projects. In fact, this approach will be really good when used with a Microfrontend architecture for your front-end projects.

    BTW, I've written an API Gateway series about Ocelot and ASP.net Core, if you want to learn more about API Gateway Architecture, you can check it out from:

    https://www.pogsdotnet.com/2018/08/api-gateway-in-nutshell.html

    Hope it helps!