Search in sources :

Example 1 with ExtensiveDomainRequestCondition

use of io.leopard.web.mvc.condition.ExtensiveDomainRequestCondition in project leopard by tanhaichao.

the class LeopardHandlerMapping method createRequestMappingInfo2.

/**
 * Created a RequestMappingInfo from a RequestMapping annotation.
 */
protected RequestMappingInfo createRequestMappingInfo2(RequestMapping annotation, Method method) {
    String[] patterns;
    if (method != null && annotation.value().length == 0) {
        patterns = new String[] { this.createPattern(method.getName()) };
    } else {
        patterns = resolveEmbeddedValuesInPatterns(annotation.value());
    }
    Map<String, String> headerMap = new LinkedHashMap<String, String>();
    ExtensiveDomain extensiveDomain = new ExtensiveDomain();
    requestMappingInfoBuilder.getHeaders(annotation, method, extensiveDomain, headerMap);
    // System.out.println("headerMap:" + headerMap);
    String[] headers = new String[headerMap.size()];
    {
        int i = 0;
        for (Entry<String, String> entry : headerMap.entrySet()) {
            String header = entry.getKey() + "=" + entry.getValue();
            headers[i] = header;
            i++;
        }
    }
    RequestCondition<?> customCondition = new ExtensiveDomainRequestCondition(extensiveDomain, headers);
    return new RequestMappingInfo(new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), false, this.useTrailingSlashMatch(), this.getFileExtensions()), new RequestMethodsRequestCondition(annotation.method()), new ParamsRequestCondition(annotation.params()), new HeadersRequestCondition(), new ConsumesRequestCondition(annotation.consumes(), headers), new ProducesRequestCondition(annotation.produces(), headers, getContentNegotiationManager()), customCondition);
}
Also used : ParamsRequestCondition(org.springframework.web.servlet.mvc.condition.ParamsRequestCondition) PatternsRequestCondition(org.springframework.web.servlet.mvc.condition.PatternsRequestCondition) RequestMappingInfo(org.springframework.web.servlet.mvc.method.RequestMappingInfo) ExtensiveDomainRequestCondition(io.leopard.web.mvc.condition.ExtensiveDomainRequestCondition) LinkedHashMap(java.util.LinkedHashMap) ExtensiveDomain(io.leopard.vhost.ExtensiveDomain) Entry(java.util.Map.Entry) ProducesRequestCondition(org.springframework.web.servlet.mvc.condition.ProducesRequestCondition) HeadersRequestCondition(org.springframework.web.servlet.mvc.condition.HeadersRequestCondition) RequestMethodsRequestCondition(org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition) ConsumesRequestCondition(org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition)

Aggregations

ExtensiveDomain (io.leopard.vhost.ExtensiveDomain)1 ExtensiveDomainRequestCondition (io.leopard.web.mvc.condition.ExtensiveDomainRequestCondition)1 LinkedHashMap (java.util.LinkedHashMap)1 Entry (java.util.Map.Entry)1 ConsumesRequestCondition (org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition)1 HeadersRequestCondition (org.springframework.web.servlet.mvc.condition.HeadersRequestCondition)1 ParamsRequestCondition (org.springframework.web.servlet.mvc.condition.ParamsRequestCondition)1 PatternsRequestCondition (org.springframework.web.servlet.mvc.condition.PatternsRequestCondition)1 ProducesRequestCondition (org.springframework.web.servlet.mvc.condition.ProducesRequestCondition)1 RequestMethodsRequestCondition (org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition)1 RequestMappingInfo (org.springframework.web.servlet.mvc.method.RequestMappingInfo)1