Configuring service consumer to use Zuul API gateway

The following code shows the existing configuration of RandomServiceProxy, which is used to call random service on Microservice A. The name attribute in the @FeignClient annotation is configured to use the application name of Microservice A. The request mapping uses the /random URI:

    @FeignClient(name ="microservice-a")    @RibbonClient(name="microservice-a")    public interface RandomServiceProxy {    @RequestMapping(value = "/random", method = RequestMethod.GET)      public List<Integer> getRandomNumbers();    }

Now, we want the call to go through the API Gateway. We would need to use the application name of the API Gateway and the new URI of random service in the request mapping. The following snippet ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.