Search in sources :

Example 1 with PathPatternsRequestCondition

use of cn.taketoday.web.handler.condition.PathPatternsRequestCondition in project today-infrastructure 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]));
    }
}
Also used : PathPatternsRequestCondition(cn.taketoday.web.handler.condition.PathPatternsRequestCondition) MediaType(cn.taketoday.http.MediaType) HandlerMatchingMetadata(cn.taketoday.web.HandlerMatchingMetadata)

Example 2 with PathPatternsRequestCondition

use of cn.taketoday.web.handler.condition.PathPatternsRequestCondition 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]));
    }
}
Also used : PathPatternsRequestCondition(cn.taketoday.web.handler.condition.PathPatternsRequestCondition) MediaType(cn.taketoday.http.MediaType) HandlerMatchingMetadata(cn.taketoday.web.HandlerMatchingMetadata)

Aggregations

MediaType (cn.taketoday.http.MediaType)2 HandlerMatchingMetadata (cn.taketoday.web.HandlerMatchingMetadata)2 PathPatternsRequestCondition (cn.taketoday.web.handler.condition.PathPatternsRequestCondition)2