Registering Zuul filters

Let's create the bean definition of these filters, as follows:

@EnableZuulProxy
@EnableDiscoveryClient
@SpringBootApplication
public class ApiZuulServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ApiZuulServiceApplication.class, args);
}
@Bean
public PreFilter preFilter() {
return new PreFilter();
}
@Bean
public PostFilter postFilter() {
return new PostFilter();
}
@Bean
public ErrorFilter errorFilter() {
return new ErrorFilter();
}
@Bean
public RouteFilter routeFilter() {
return new RouteFilter();
}
}

Let's run the preceding class again and access any public API Gateway service for Customer or Account and check the console of the eclipse:

As you can see in the console log, as we have refreshed the http://192.168.225.208:8080/api/customers/customer/1001 API call, all filters are executed and print log on the console, respectively.

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

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