use of cn.taketoday.web.HandlerMatchingMetadata in project today-framework by TAKETODAY.
the class RequestMappingInfoHandlerMapping method handleMatch.
/**
* Expose URI template variables, matrix variables, and producible media types in the request.
*/
@Override
protected void handleMatch(Match bestMatch, String lookupPath, RequestContext request) {
super.handleMatch(bestMatch, lookupPath, request);
RequestMappingInfo info = bestMatch.mapping;
PathPatternsRequestCondition pathPatternsCondition = info.getPathPatternsCondition();
HandlerMatchingMetadata matchingMetadata = new HandlerMatchingMetadata(bestMatch.getHandlerMethod(), lookupPath, request.getLookupPath(), CollectionUtils.firstElement(pathPatternsCondition.getPatterns()), getPatternParser());
request.setMatchingMetadata(matchingMetadata);
Set<MediaType> mediaTypes = info.getProducesCondition().getProducibleMediaTypes();
if (!mediaTypes.isEmpty()) {
matchingMetadata.setProducibleMediaTypes(mediaTypes.toArray(new MediaType[0]));
}
}
use of cn.taketoday.web.HandlerMatchingMetadata in project today-framework by TAKETODAY.
the class AbstractView method createMergedOutputModel.
/**
* Creates a combined output Map (never {@code null}) that includes dynamic values and static attributes.
* Dynamic values take precedence over static attributes.
*/
protected Map<String, Object> createMergedOutputModel(@Nullable Map<String, ?> model, RequestContext context) {
// Consolidate static and dynamic model attributes.
Map<String, Object> staticAttributes = getStaticAttributes();
int size = model != null ? model.size() : 0;
if (staticAttributes != null) {
size += staticAttributes.size();
}
Map<String, String> pathVars = null;
HandlerMatchingMetadata matchingMetadata = context.getMatchingMetadata();
if (exposePathVariables && matchingMetadata != null) {
pathVars = matchingMetadata.getUriVariables();
size += pathVars.size();
}
Map<String, Object> mergedModel = CollectionUtils.newLinkedHashMap(size);
if (CollectionUtils.isNotEmpty(staticAttributes)) {
mergedModel.putAll(staticAttributes);
}
if (CollectionUtils.isNotEmpty(pathVars)) {
mergedModel.putAll(pathVars);
}
if (CollectionUtils.isNotEmpty(model)) {
mergedModel.putAll(model);
}
// Expose RequestContext?
if (requestContextAttribute != null) {
mergedModel.put(requestContextAttribute, context);
}
return mergedModel;
}
use of cn.taketoday.web.HandlerMatchingMetadata in project today-framework by TAKETODAY.
the class PathVariableMapMethodArgumentResolverTests method applyTemplateVars.
private void applyTemplateVars() {
RequestPath requestPath = RequestPath.parse("/mock/value", null);
PathPattern pathPattern = PathPatternParser.defaultInstance.parse("/mock/{name}");
HandlerMatchingMetadata matchingMetadata = new HandlerMatchingMetadata(new Object(), "/mock", requestPath, pathPattern, PathPatternParser.defaultInstance);
webRequest.setMatchingMetadata(matchingMetadata);
}
use of cn.taketoday.web.HandlerMatchingMetadata in project today-framework by TAKETODAY.
the class PathVariableMethodArgumentResolverTests method applyTemplateVars.
private void applyTemplateVars(String name, String value) {
RequestPath requestPath = RequestPath.parse("/mock/" + value, null);
PathPattern pathPattern = PathPatternParser.defaultInstance.parse("/mock/{" + name + "}");
HandlerMatchingMetadata matchingMetadata = new HandlerMatchingMetadata(new Object(), "/mock", requestPath, pathPattern, PathPatternParser.defaultInstance);
webRequest.setMatchingMetadata(matchingMetadata);
}
use of cn.taketoday.web.HandlerMatchingMetadata in project today-framework by TAKETODAY.
the class PathVariableMethodArgumentResolverTests method applyTemplateVars.
private void applyTemplateVars() {
RequestPath requestPath = RequestPath.parse("/mock/value", null);
PathPattern pathPattern = PathPatternParser.defaultInstance.parse("/mock/{name}");
HandlerMatchingMetadata matchingMetadata = new HandlerMatchingMetadata(new Object(), "/mock", requestPath, pathPattern, PathPatternParser.defaultInstance);
webRequest.setMatchingMetadata(matchingMetadata);
}
Aggregations