-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composite / Stereotype Filters #3589
Comments
I don't know if boot supports yaml anchor references. @philwebb do you know? |
I'm pretty sure we don't have any tests for yaml anchor references, so they're certainly not officially supported. We rely on SnakeYAML to do the actual parsing, and I don't know how that deals with them. I've opened spring-projects/spring-boot#43125 to investigate. |
@philwebb @spencergibb So it turns out that anchors do "just work", i just had some syntactical issues. But they unfortunately specifically don't support my desired use case (merging elements of a sequence) yaml/yaml#35 So it appears I'm back to square 0. Any suggestions on a mechanism to perhaps programmatically trigger adding a set of Filters to given yaml-defined route (at startup) such that the actual filter execution order follows the order defined by the |
You could let Spring Boot do the list conversion then try something like this: type-a-filters: "Filter1, Filter2, Filter3"
filters: "${type-a-filter}, Filter10" When |
Unless the filters have no arguments that's not going to work either. |
@spencergibb That's a good point - a single shortcut configuration param works e.g. this seems fine: type-a-filters: "Filter1, Filter2, Filter3=foo"
filters: "${type-a-filter}, Filter10=bar" but if i actually have to specify out a nested configuration structure, or provide multiple comma delimited shortcut params... that doesn't work. :( |
Let's say I have a different types of routes in my application, routes of
Type A
andType B
.And my application has filters:
Filter1
,Filter2
...Filter10
For
Type A
routes I want to always apply Filters1,2,3,4,5
and forType B
routes I always want to apply Filters6,7,8
.Filter9
andFilter10
may by applied to either type of route.Rather than having to copy/paste and specify each of the individual filters on every single route in my application, I'd love some mechanism to create Composite sets of filters that should be applied.
So for a route of
Type A
instead of:I could write something like:
I attempted to do this via creating an
TypeAGatewayFilterFactory
that simply invokes 1,2,3,4,5 in turn, but this is not ideal as it doesn't respect the global ordering of theOrderedFilter
s the filters will always be applied immediately after the ordering of theTypeA
OrderedFilter
in the specific sequence they're applied.I also attempted to use a yaml anchor reference e.g.
But i got a errors like:
Is there any alternate mechanism I should be considering to enable these types of Composite Filters?
The text was updated successfully, but these errors were encountered: