spring-cloud-gateway
spring-cloud-gateway copied to clipboard
make GatewayFilter created by GatewayFilterFacotory supports setting different order for each route.
the rateLimiter GatewayFilter was spawned by RequestRateLimiterGatewayFilterFactory, but I noticed I can't specify the order of it unless I overwrite it and wrap it into a OrderedGatewayFilter, even though overwrite and set order works for a singular route, but if there are multiple routes using this filter and want to set different order, then it won't work. If I have a application.yml like following:
routes:
- id: commonBiz1
uri: lb://commonBiz1
predicates:
- Path=/commonBiz1/**
filters:
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 1
redis-rate-limiter.burstCapacity: 2
redis-rate-limiter.requestedTokens: 1
# implement this application.yml property to set order for different route
filter-order: -100
Is there a way to let gatewayFilterFactory returns OrderedGatewayFilter with different order by different order setting per route?
+1 on this. I see great utility in allowing a filter order specified in application.yaml
.
+1 on this.
I don't understand the need for this. If the filter is first in a route it is the first route filter to run. Can someone clarify why they need it?
Hi, @spencergibb . In my app i use default filters with custom filters depending on the URL path. And I want to run 2...3 default filters, then several custom filters, and then again some default filters. But now all default filters start first, then all custom filters.