I use Spring Cloud Zuul to proxy some API requests to multiple external servers. The proxy server itself works well, but each service requires a (different) token specified in the request header.
I have successfully written a simple pre-filter for each token that applies the corresponding header. However, I now have a problem. Even after uploading the documentation, I cannot figure out how to make each filter apply only to the correct route. I do not want to perform url mapping as the URL changes in different environments. Ideally, I would have a way to get the route name in the filter.
My application.yml:
zuul:
routes:
foo:
path: /foo/**
url: https://fooserver.com
bar:
path: /bar/**
url: https://barserver.com
Ideally, I would like to do something like this in FooFilter.java (prefilter):
public bool shouldFilter() {
return RequestContext.getCurrentContext().getRouteName().equals("foo");
}
.