spring-cloud-gateway
spring-cloud-gateway copied to clipboard
Add default filters to routes create by route DSL
Hi
I define a route using API don't support for default filter.
this is my code
@Bean
public RouteLocator hiServerRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("hi-server", r -> r.path("/hi-server/**")
.filters(f -> f.rewritePath("/hi-server/(?<remaining>.*)", "/${remaining}")
).uri("lb://hi"))
.build();
}
define a default filter in configure file
spring:
application:
name: gateway
cloud:
gateway:
default-filters:
- name: AddResponseHeader
args:
name: X-Response-Default-Foo
value: Default-Bar
access the url http://localhost:9999/hi/hi
HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/plain;charset=UTF-8
Date: Mon, 02 Apr 2018 02:11:13 GMT
X-Response-Default-Foo: Default-Bar # default filter is work
hi!
access the url http://localhost:9999/hi-server/hi
HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/plain;charset=UTF-8
Date: Mon, 02 Apr 2018 02:12:39 GMT
# default filter don't work
hi!
Java routes API don't support for default filters or how to do it ?
The spring cloud gateway version is 2.0.0.M9
Would be really useful bit blocked from using gateway as I can't use yaml config because I need or()
& alwaysTrue
and can't use java config because I need default filters.
I'm currently declaring routes with with RouterFunctions.route()
passing a HandlerFunction that make calls to different microservices. Having the ability to use default filters via configuration would unlock many cloud gateway functionalities in this case. :)
Not sure how that relates add that comes from webflux and gateway filters don't apply there
Got same problem when use
Any updates?
Would this be fixed soon? I am also facing issue...
This would be nice to have fixed. We have a bunch of routes that configure CORS and come back with duplicate response headers so each java DSL route has to have that DedupeResponseHeader filter