Enabling the Zuul service proxy

Now add the @EnableZuulProxy annotation on top of the ApiZuulServiceApplication Spring Boot application class. This annotation will enable the Zuul service proxy in our application and will also enable all the features of an API Gateway layer. Along with the @EnableZuulproxy annotation, we have also added another @EnableDiscoveryClient annotation on top of the ApiZuulServiceApplication class. Let's see the following main application class of the api-gateway-service application:

package com.dineshonjava.apizuulservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
@EnableZuulProxy
@EnableDiscoveryClient
@SpringBootApplication
public class ApiZuulServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ApiZuulServiceApplication.class, args);
}
}

As you can see, the ApiZuulServiceApplication class is annotated with the @EnableZuulProxy annotation to enable the Zuul proxy service in our microservice application. Now, we will see how to configure Zuul properties in our application.properties or application.yml file. In this chapter, I have used the application.yml configuration file to configure Zuul properties, but we can also use the bootstrap.properties file to configure come configurations that are required at the startup time of the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.255.178