Search in sources :

Example 6 with RequestedContentTypeResolverBuilder

use of org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder in project spring-framework by spring-projects.

the class ResponseEntityResultHandlerTests method createHandler.

private ResponseEntityResultHandler createHandler(HttpMessageWriter<?>... writers) {
    List<HttpMessageWriter<?>> writerList;
    if (ObjectUtils.isEmpty(writers)) {
        writerList = new ArrayList<>();
        writerList.add(new EncoderHttpMessageWriter<>(new ByteBufferEncoder()));
        writerList.add(new EncoderHttpMessageWriter<>(new CharSequenceEncoder()));
        writerList.add(new ResourceHttpMessageWriter());
        writerList.add(new EncoderHttpMessageWriter<>(new Jaxb2XmlEncoder()));
        writerList.add(new EncoderHttpMessageWriter<>(new Jackson2JsonEncoder()));
    } else {
        writerList = Arrays.asList(writers);
    }
    RequestedContentTypeResolver resolver = new RequestedContentTypeResolverBuilder().build();
    return new ResponseEntityResultHandler(writerList, resolver);
}
Also used : ByteBufferEncoder(org.springframework.core.codec.ByteBufferEncoder) ResourceHttpMessageWriter(org.springframework.http.codec.ResourceHttpMessageWriter) EncoderHttpMessageWriter(org.springframework.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(org.springframework.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(org.springframework.http.codec.ResourceHttpMessageWriter) RequestedContentTypeResolver(org.springframework.web.reactive.accept.RequestedContentTypeResolver) CharSequenceEncoder(org.springframework.core.codec.CharSequenceEncoder) Jaxb2XmlEncoder(org.springframework.http.codec.xml.Jaxb2XmlEncoder) Jackson2JsonEncoder(org.springframework.http.codec.json.Jackson2JsonEncoder) RequestedContentTypeResolverBuilder(org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder)

Aggregations

RequestedContentTypeResolverBuilder (org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder)6 ByteBufferEncoder (org.springframework.core.codec.ByteBufferEncoder)3 CharSequenceEncoder (org.springframework.core.codec.CharSequenceEncoder)3 EncoderHttpMessageWriter (org.springframework.http.codec.EncoderHttpMessageWriter)3 HttpMessageWriter (org.springframework.http.codec.HttpMessageWriter)3 ResourceHttpMessageWriter (org.springframework.http.codec.ResourceHttpMessageWriter)3 Jackson2JsonEncoder (org.springframework.http.codec.json.Jackson2JsonEncoder)3 Jaxb2XmlEncoder (org.springframework.http.codec.xml.Jaxb2XmlEncoder)3 RequestedContentTypeResolver (org.springframework.web.reactive.accept.RequestedContentTypeResolver)3 Test (org.junit.Test)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 Resource (org.springframework.core.io.Resource)2 UrlResource (org.springframework.core.io.UrlResource)2 MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)2 CompositeContentTypeResolver (org.springframework.web.reactive.accept.CompositeContentTypeResolver)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Bean (org.springframework.context.annotation.Bean)1 MediaType (org.springframework.http.MediaType)1