Home > Blockchain >  Calling another endpoint from the same controller
Calling another endpoint from the same controller

Time:01-29

I have a controller in which i have one endpoint (say endpoint1) after consuming data from endpoint1 ,we check some conditions and we need to call endpoint2. How to design this requirement using springboot

Can i directly consume endpoint2 from service layer?

CodePudding user response:

Whether the endpoint2 is an external service or its own service If it's an external service, you need to use resttemplate to call it. If it's internal, just call the service logic directly

CodePudding user response:

You can and should use API instead of directly calling the service logic. This will help in reusability as well as the abstraction layer will avoid coupling between your services.

You can use RestTemplate or WebClient (for spring version >= 5) to call API from within the service layer.

  • Related