Search in sources :

Example 1 with RequestMatchResult

use of org.springframework.web.servlet.handler.RequestMatchResult in project spring-framework by spring-projects.

the class RequestMappingHandlerMapping method match.

@Override
public RequestMatchResult match(HttpServletRequest request, String pattern) {
    RequestMappingInfo info = RequestMappingInfo.paths(pattern).options(this.config).build();
    RequestMappingInfo matchingInfo = info.getMatchingCondition(request);
    if (matchingInfo == null) {
        return null;
    }
    Set<String> patterns = matchingInfo.getPatternsCondition().getPatterns();
    String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
    return new RequestMatchResult(patterns.iterator().next(), lookupPath, getPathMatcher());
}
Also used : RequestMatchResult(org.springframework.web.servlet.handler.RequestMatchResult) RequestMappingInfo(org.springframework.web.servlet.mvc.method.RequestMappingInfo)

Example 2 with RequestMatchResult

use of org.springframework.web.servlet.handler.RequestMatchResult in project spring-security by spring-projects.

the class MvcRequestMatcher method extractUriTemplateVariables.

/*
	 * (non-Javadoc)
	 *
	 * @see org.springframework.security.web.util.matcher.RequestVariablesExtractor#
	 * extractUriTemplateVariables(javax.servlet.http.HttpServletRequest)
	 */
@Override
public Map<String, String> extractUriTemplateVariables(HttpServletRequest request) {
    MatchableHandlerMapping mapping = getMapping(request);
    if (mapping == null) {
        return this.defaultMatcher.extractUriTemplateVariables(request);
    }
    RequestMatchResult result = mapping.match(request, this.pattern);
    return result == null ? Collections.<String, String>emptyMap() : result.extractUriTemplateVariables();
}
Also used : MatchableHandlerMapping(org.springframework.web.servlet.handler.MatchableHandlerMapping) RequestMatchResult(org.springframework.web.servlet.handler.RequestMatchResult)

Example 3 with RequestMatchResult

use of org.springframework.web.servlet.handler.RequestMatchResult in project spring-security by spring-projects.

the class MvcRequestMatcher method matches.

@Override
public boolean matches(HttpServletRequest request) {
    if (this.method != null && !this.method.name().equals(request.getMethod())) {
        return false;
    }
    if (this.servletPath != null && !this.servletPath.equals(request.getServletPath())) {
        return false;
    }
    MatchableHandlerMapping mapping = getMapping(request);
    if (mapping == null) {
        return this.defaultMatcher.matches(request);
    }
    RequestMatchResult matchResult = mapping.match(request, this.pattern);
    return matchResult != null;
}
Also used : MatchableHandlerMapping(org.springframework.web.servlet.handler.MatchableHandlerMapping) RequestMatchResult(org.springframework.web.servlet.handler.RequestMatchResult)

Aggregations

RequestMatchResult (org.springframework.web.servlet.handler.RequestMatchResult)3 MatchableHandlerMapping (org.springframework.web.servlet.handler.MatchableHandlerMapping)2 RequestMappingInfo (org.springframework.web.servlet.mvc.method.RequestMappingInfo)1