spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

make GatewayFilter created by GatewayFilterFacotory supports setting different order for each route.

Open yili001 opened this issue 2 years ago • 2 comments

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?

yili001 avatar Jul 09 '22 06:07 yili001

+1 on this. I see great utility in allowing a filter order specified in application.yaml.

JesseEstum avatar Nov 06 '23 19:11 JesseEstum

+1 on this.

IvanLinnik avatar Feb 19 '24 13:02 IvanLinnik

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?

spencergibb avatar Mar 13 '24 19:03 spencergibb

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.

IvanLinnik avatar Mar 14 '24 14:03 IvanLinnik