How to create multiple (pre/post) filters in zuul gateway app (spring boot).
Example:
/endpoint1 - should call (Filter 1)
/endpoint2 - should be served by (Filter2)
Currently I understand that every request comes to gateway, will be handled by one Filter (pre, route,post)
You can use multiple filters for one endpoints or many endpoints.
If you want to apply filter for some endpoints and not for others, you can use the shouldFilter()
method of this filter (e.g pre filter) to define the use case. Something like :
@Override
public boolean shouldFilter() {
String endpointToFilter = RequestContext.getCurrentContext().getRequest().getRequestURI();
endpointToFilter = endpointToFilter.substring(0, endpointToFilter.indexOf("/", 1));
boolean shouldFilter = "endpoint1".equals(endpointToFilter);
return shouldFilter;
}