-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
There seems to be an asymmetry between MVC and Webflux with the AbstractUrlHandlerMapping
. The MVC one parses out the URI variables and dumps them in a request attribute. The Webflux one does not. Here's what I did:
class MyHandlerMapping extends AbstractUrlHandlerMapping {
@Override
protected Object lookupHandler(PathContainer lookupPath, ServerWebExchange exchange) throws Exception {
Object result = super.lookupHandler(lookupPath, exchange);
if (result == null) {
return result;
}
PathPattern bestPattern = (PathPattern) exchange.getAttributes().get(BEST_MATCHING_PATTERN_ATTRIBUTE);
Map<String, String> uriVariables;
Map<String, MultiValueMap<String, String>> matrixVariables;
if (bestPattern == null) {
bestPattern = getPathPatternParser().parse(lookupPath.value());
uriVariables = Collections.emptyMap();
matrixVariables = Collections.emptyMap();
}
else {
PathPattern.PathMatchInfo match = bestPattern.matchAndExtract(lookupPath);
Assert.notNull(match, () ->
"Expected pattern to match lookupPath " + lookupPath);
uriVariables = match.getUriVariables();
matrixVariables = match.getMatrixVariables();
}
exchange.getAttributes().put(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables);
exchange.getAttributes().put(MATRIX_VARIABLES_ATTRIBUTE, matrixVariables);
return result;
}
...
(Code copied from RequestMappingInfoHandlerMapping.handleMatch
.)
Would it be reasonable for that to be the default?
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement