/** * Extract URI template variables from the matching pattern as defined in * {@link PathMatcher#extractUriTemplateVariables}. * @return a map with URI template variables */ public Map<String, String> extractUriTemplateVariables() { return this.pathMatcher.extractUriTemplateVariables(this.matchingPattern, this.lookupPath); }
/** * Extract URI template variables from the matching pattern as defined in * {@link PathMatcher#extractUriTemplateVariables}. * @return a map with URI template variables */ public Map<String, String> extractUriTemplateVariables() { return this.pathMatcher.extractUriTemplateVariables(this.matchingPattern, this.lookupPath); }
public Map<String, String> extractUriTemplateVariables(String pattern, String path) { return delegate.extractUriTemplateVariables(pattern, path); }
public Map<String, String> extractUriTemplateVariables(String pattern, String path) { return delegate.extractUriTemplateVariables(pattern, path); }
@Override protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod, String lookupDestination, Message<?> message) { Set<String> patterns = mapping.getDestinationConditions().getPatterns(); if (!CollectionUtils.isEmpty(patterns)) { String pattern = patterns.iterator().next(); Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(pattern, lookupDestination); if (!CollectionUtils.isEmpty(vars)) { MessageHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class); Assert.state(mha != null && mha.isMutable(), "Mutable MessageHeaderAccessor required"); mha.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars); } } try { SimpAttributesContextHolder.setAttributesFromMessage(message); super.handleMatch(mapping, handlerMethod, lookupDestination, message); } finally { SimpAttributesContextHolder.resetAttributes(); } }
for (String matchingPattern : matchingPatterns) { if (patternComparator.compare(bestMatch, matchingPattern) == 0) { Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(matchingPattern, urlPath); Map<String, String> decodedVars = getUrlPathHelper().decodePathVariables(request, vars); uriTemplateVariables.putAll(decodedVars);
uriVariables = getPathMatcher().extractUriTemplateVariables(bestPattern, lookupPath);
@Override public Predicate<ServerWebExchange> apply(Config config) { return exchange -> { String host = exchange.getRequest().getHeaders().getFirst("Host"); Optional<String> optionalPattern = config.getPatterns().stream() .filter(pattern -> this.pathMatcher.match(pattern, host)) .findFirst(); if (optionalPattern.isPresent()) { Map<String, String> variables = this.pathMatcher.extractUriTemplateVariables(optionalPattern.get(), host); ServerWebExchangeUtils.putUriTemplateVariables(exchange, variables); return true; } return false; }; }
uriVariables = getPathMatcher().extractUriTemplateVariables(bestPattern, lookupPath);
for (String matchingPattern : matchingPatterns) { if (patternComparator.compare(bestMatch, matchingPattern) == 0) { Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(matchingPattern, urlPath); Map<String, String> decodedVars = getUrlPathHelper().decodePathVariables(request, vars); uriTemplateVariables.putAll(decodedVars);
public Map<String, String> extractUriTemplateVariables(String pattern, String path) { return delegate.extractUriTemplateVariables(pattern, path); }
public Map<String, String> extractUriTemplateVariables(String pattern, String path) { return delegate.extractUriTemplateVariables(pattern, path); }
@Override protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod, String lookupDestination, Message<?> message) { Set<String> patterns = mapping.getDestinationConditions().getPatterns(); if (!CollectionUtils.isEmpty(patterns)) { String pattern = patterns.iterator().next(); Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(pattern, lookupDestination); if (!CollectionUtils.isEmpty(vars)) { MessageHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class); Assert.state(mha != null && mha.isMutable(), "Mutable MessageHeaderAccessor required"); mha.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars); } } try { SimpAttributesContextHolder.setAttributesFromMessage(message); super.handleMatch(mapping, handlerMethod, lookupDestination, message); } finally { SimpAttributesContextHolder.resetAttributes(); } }
if (pattern == null) return Collections.emptyMap(); return target.extractUriTemplateVariables(pattern, path);
@Override public Map<String, String> extractUriTemplateVariables(String pattern, String path) { return delagateMatcher.extractUriTemplateVariables(pattern, path); }
/** * Extract URI template variables from the matching pattern as defined in * {@link PathMatcher#extractUriTemplateVariables}. * @return a map with URI template variables */ public Map<String, String> extractUriTemplateVariables() { return this.pathMatcher.extractUriTemplateVariables(this.matchingPattern, this.lookupPath); }
public static String getUriVariableValue(final HttpServletRequest request, final String pattern, final String variable) { final Map<String, String> uriVariables = pathMatcher.extractUriTemplateVariables(pattern, URL_PATH_HELPER.getLookupPathForRequest(request)); return uriVariables.get(variable); }
@Override public Map<String, String> extractUriTemplateVariables( HttpServletRequest request) { String lookupPath = this.pathHelper.getLookupPathForRequest(request); if (matches(lookupPath)) { return this.pathMatcher.extractUriTemplateVariables( MvcRequestMatcher.this.pattern, lookupPath); } return Collections.emptyMap(); } }
@SuppressWarnings("unchecked") private void extractHandlerMethodUriTemplates(String mappedPattern, String lookupPath, HttpServletRequest request) { Map<String, String> variables = (Map<String, String>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); int patternVariableCount = StringUtils.countOccurrencesOf(mappedPattern, "{"); if ((variables == null || patternVariableCount != variables.size()) && pathMatcher.match(mappedPattern, lookupPath)) { variables = pathMatcher.extractUriTemplateVariables(mappedPattern, lookupPath); Map<String, String> decodedVariables = urlPathHelper.decodePathVariables(request, variables); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, decodedVariables); } } }
public void prepare(ApiMethodMapping mapping, HttpContextRequest request, Object ... args){ if(null != args && args.length>0 && args[0] instanceof PathMatcher) { PathMatcher matcher = (PathMatcher) args[0]; if (request.getAttachment(ApiMethodParamResolver.ATTACHMENT_API_METHOD_PATH_VARIABLE_KEY) == null) { Map<String, String> pathVariables = matcher.extractUriTemplateVariables(mapping.getUrlPattern(), request.getRequestUrl()); request.addAttachment(ApiMethodParamResolver.ATTACHMENT_API_METHOD_PATH_VARIABLE_KEY, pathVariables); } } } }