|
|
|
@ -16,6 +16,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.web.reactive.function.server; |
|
|
|
package org.springframework.web.reactive.function.server; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.function.Function; |
|
|
|
@ -460,12 +462,28 @@ public abstract class RouterFunctions { |
|
|
|
"Nested predicate \"%s\" matches against \"%s\"", |
|
|
|
"Nested predicate \"%s\" matches against \"%s\"", |
|
|
|
this.predicate, serverRequest)); |
|
|
|
this.predicate, serverRequest)); |
|
|
|
} |
|
|
|
} |
|
|
|
return this.routerFunction.route(nestedRequest); |
|
|
|
return this.routerFunction.route(nestedRequest) |
|
|
|
|
|
|
|
.doOnNext(match -> { |
|
|
|
|
|
|
|
mergeTemplateVariables(serverRequest, nestedRequest.pathVariables()); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
.orElseGet(Mono::empty); |
|
|
|
.orElseGet(Mono::empty); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
|
|
|
private void mergeTemplateVariables(ServerRequest request, Map<String, String> variables) { |
|
|
|
|
|
|
|
if (!variables.isEmpty()) { |
|
|
|
|
|
|
|
Map<String, Object> attributes = request.attributes(); |
|
|
|
|
|
|
|
Map<String, String> oldVariables = (Map<String, String>)request.attribute(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE) |
|
|
|
|
|
|
|
.orElseGet(LinkedHashMap::new); |
|
|
|
|
|
|
|
Map<String, String> mergedVariables = new LinkedHashMap<>(oldVariables); |
|
|
|
|
|
|
|
mergedVariables.putAll(variables); |
|
|
|
|
|
|
|
attributes.put(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE, |
|
|
|
|
|
|
|
Collections.unmodifiableMap(mergedVariables)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void accept(Visitor visitor) { |
|
|
|
public void accept(Visitor visitor) { |
|
|
|
visitor.startNested(this.predicate); |
|
|
|
visitor.startNested(this.predicate); |
|
|
|
|