Spring WebFlux Adapter Support "BEST_MATCHING_PATTERN_ATTRIBUTE"#2628
Open
icodening wants to merge 4 commits intoalibaba:masterfrom
Open
Spring WebFlux Adapter Support "BEST_MATCHING_PATTERN_ATTRIBUTE"#2628icodening wants to merge 4 commits intoalibaba:masterfrom
icodening wants to merge 4 commits intoalibaba:masterfrom
Conversation
sczyh30
requested changes
Mar 30, 2022
Member
sczyh30
left a comment
There was a problem hiding this comment.
Could you please add test cases for this feature?
Contributor
Author
OK,I will add test case soon |
Contributor
Author
I have added test code, please review |
|
Why is this feature not merged, is there any problem? |
Contributor
|
能否不修改SentinelWebFluxFilter,而通过 我们是否可以类似这样 |
wuwen5
reviewed
Dec 8, 2022
| return this.exchange.getRequest(); | ||
| } | ||
|
|
||
| public ServerWebExchange exchange() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
Spring WebFlux下使用Sentinel,支持将Path参数的路径视为同一资源。
如在 /users/{id} 下,/users/1、/users/2将被视为同一个资源 "/users/{id}"
Does this pull request fix one issue?
Fixes #2627
Describe how you did it
在SentinelWebFluxFilter中获取path动作之前加入获取"BEST_MATCHING_PATTERN_ATTRIBUTE"的埋点,如果埋点获取的结果为空,则使用默认的获取资源名逻辑

Describe how to verify it
需要使用新的方式装配 SentinelWebFluxFilter,方式如下
Special notes for reviews
下图为大致流程图可帮助理解

其中,HandlerMappingBestMatchingPatternExtractor接口有两个默认实现分别为RequestMappingHandlerMappingBestMatchingPatternExtractor, RouterFunctionMappingBestMatchingPatternExtractor. 两个提取器分别处理RequestMappingHandlerMapping与RouterFunctionMapping