Example usage for org.springframework.web.servlet.mvc.condition ConsumesRequestCondition ConsumesRequestCondition

List of usage examples for org.springframework.web.servlet.mvc.condition ConsumesRequestCondition ConsumesRequestCondition

Introduction

In this page you can find the example usage for org.springframework.web.servlet.mvc.condition ConsumesRequestCondition ConsumesRequestCondition.

Prototype

public ConsumesRequestCondition(String[] consumes, @Nullable String[] headers) 

Source Link

Document

Creates a new instance with "consumes" and "header" expressions.

Usage

From source file:net.sf.cocmvc.ConventionalHandlerMapping.java

private RequestMappingInfo createRequestMapping(RequestMapping annotation,
        RequestCondition<?> customCondition) {
    return new RequestMappingInfo(createPatternRequestCondition(annotation.value()),
            new RequestMethodsRequestCondition(annotation.method()),
            new ParamsRequestCondition(annotation.params()), new HeadersRequestCondition(annotation.headers()),
            new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
            new ProducesRequestCondition(annotation.produces(), annotation.headers()), customCondition);
}

From source file:org.makersoft.mvc.method.annotation.RESTfulMappingHandlerMapping.java

/**
 * Created a RequestMappingInfo from a RequestMapping annotation.
 *///from   w ww  .java  2s . c o m
private RequestMappingInfo createRequestMappingInfo(Method method, RESTfull annotation,
        Class<?> controllerClass) {

    Mapping mapping = RESTfulHelper.matchMapping(method.getName());

    if (mapping != null) {
        PackageBasedUrlPathBuilder builder = new PackageBasedUrlPathBuilder(packageLocators, controllerPackages,
                controllerSuffix, root);

        String[] namespaceString = builder.buildUrlPath(controllerClass, mapping.getMethodName(),
                mapping.getValues());
        if (namespaceString != null) {
            return new RequestMappingInfo(
                    new PatternsRequestCondition(namespaceString, getUrlPathHelper(), getPathMatcher(),
                            this.useSuffixPatternMatch, this.useTrailingSlashMatch),
                    new RequestMethodsRequestCondition(mapping.getRequestMethods()),
                    new ParamsRequestCondition(mapping.getParams()),
                    new HeadersRequestCondition(mapping.getHeaders()),
                    new ConsumesRequestCondition(mapping.getConsumes(), mapping.getHeaders()),
                    new ProducesRequestCondition(mapping.getProduces(), mapping.getHeaders()),
                    getCustomMethodCondition(method));
        }

    }

    return null;
}