T
- the type of objects in the decoded output streampublic class DecoderHttpMessageReader<T> extends java.lang.Object implements HttpMessageReader<T>
HttpMessageReader
that wraps and delegates to a Decoder
.
Also a HttpMessageReader
that pre-resolves decoding hints
from the extra information available on the server side such as the request
or controller method parameter annotations.
Constructor and Description |
---|
DecoderHttpMessageReader(org.springframework.core.codec.Decoder<T> decoder)
Create an instance wrapping the given
Decoder . |
Modifier and Type | Method and Description |
---|---|
boolean |
canRead(org.springframework.core.ResolvableType elementType,
MediaType mediaType)
Whether the given object type is supported by this reader.
|
protected MediaType |
getContentType(HttpMessage inputMessage)
Determine the Content-Type of the HTTP message based on the
"Content-Type" header or otherwise default to
MediaType.APPLICATION_OCTET_STREAM . |
org.springframework.core.codec.Decoder<T> |
getDecoder()
Return the
Decoder of this reader. |
java.util.List<MediaType> |
getReadableMediaTypes()
Return the
MediaType 's that this reader supports. |
protected java.util.Map<java.lang.String,java.lang.Object> |
getReadHints(org.springframework.core.ResolvableType actualType,
org.springframework.core.ResolvableType elementType,
ServerHttpRequest request,
ServerHttpResponse response)
Get additional hints for decoding for example based on the server request
or annotations from controller method parameters.
|
reactor.core.publisher.Flux<T> |
read(org.springframework.core.ResolvableType elementType,
ReactiveHttpInputMessage message,
java.util.Map<java.lang.String,java.lang.Object> hints)
Read from the input message and encode to a stream of objects.
|
reactor.core.publisher.Flux<T> |
read(org.springframework.core.ResolvableType actualType,
org.springframework.core.ResolvableType elementType,
ServerHttpRequest request,
ServerHttpResponse response,
java.util.Map<java.lang.String,java.lang.Object> hints)
Server-side only alternative to
HttpMessageReader.read(ResolvableType, ReactiveHttpInputMessage, Map)
with additional context available. |
reactor.core.publisher.Mono<T> |
readMono(org.springframework.core.ResolvableType elementType,
ReactiveHttpInputMessage message,
java.util.Map<java.lang.String,java.lang.Object> hints)
Read from the input message and encode to a single object.
|
reactor.core.publisher.Mono<T> |
readMono(org.springframework.core.ResolvableType actualType,
org.springframework.core.ResolvableType elementType,
ServerHttpRequest request,
ServerHttpResponse response,
java.util.Map<java.lang.String,java.lang.Object> hints)
Server-side only alternative to
HttpMessageReader.readMono(ResolvableType, ReactiveHttpInputMessage, Map)
with additional, context available. |
public DecoderHttpMessageReader(org.springframework.core.codec.Decoder<T> decoder)
Decoder
.public org.springframework.core.codec.Decoder<T> getDecoder()
Decoder
of this reader.public java.util.List<MediaType> getReadableMediaTypes()
HttpMessageReader
MediaType
's that this reader supports.getReadableMediaTypes
in interface HttpMessageReader<T>
public boolean canRead(org.springframework.core.ResolvableType elementType, @Nullable MediaType mediaType)
HttpMessageReader
canRead
in interface HttpMessageReader<T>
elementType
- the type of object to checkmediaType
- the media type for the read (possibly null
)true
if readable, false
otherwisepublic reactor.core.publisher.Flux<T> read(org.springframework.core.ResolvableType elementType, ReactiveHttpInputMessage message, java.util.Map<java.lang.String,java.lang.Object> hints)
HttpMessageReader
read
in interface HttpMessageReader<T>
elementType
- the type of objects in the stream which must have been
previously checked via HttpMessageReader.canRead(ResolvableType, MediaType)
message
- the message to read fromhints
- additional information about how to read and decode the inputpublic reactor.core.publisher.Mono<T> readMono(org.springframework.core.ResolvableType elementType, ReactiveHttpInputMessage message, java.util.Map<java.lang.String,java.lang.Object> hints)
HttpMessageReader
readMono
in interface HttpMessageReader<T>
elementType
- the type of objects in the stream which must have been
previously checked via HttpMessageReader.canRead(ResolvableType, MediaType)
message
- the message to read fromhints
- additional information about how to read and decode the input@Nullable protected MediaType getContentType(HttpMessage inputMessage)
MediaType.APPLICATION_OCTET_STREAM
.inputMessage
- the HTTP messagenull
.public reactor.core.publisher.Flux<T> read(org.springframework.core.ResolvableType actualType, org.springframework.core.ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, java.util.Map<java.lang.String,java.lang.Object> hints)
HttpMessageReader
HttpMessageReader.read(ResolvableType, ReactiveHttpInputMessage, Map)
with additional context available.read
in interface HttpMessageReader<T>
actualType
- the actual type of the target method parameter;
for annotated controllers, the MethodParameter
can be accessed
via ResolvableType.getSource()
.elementType
- the type of Objects in the output streamrequest
- the current requestresponse
- the current responsehints
- additional information about how to read the bodypublic reactor.core.publisher.Mono<T> readMono(org.springframework.core.ResolvableType actualType, org.springframework.core.ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, java.util.Map<java.lang.String,java.lang.Object> hints)
HttpMessageReader
HttpMessageReader.readMono(ResolvableType, ReactiveHttpInputMessage, Map)
with additional, context available.readMono
in interface HttpMessageReader<T>
actualType
- the actual type of the target method parameter;
for annotated controllers, the MethodParameter
can be accessed
via ResolvableType.getSource()
.elementType
- the type of Objects in the output streamrequest
- the current requestresponse
- the current responsehints
- additional information about how to read the bodyprotected java.util.Map<java.lang.String,java.lang.Object> getReadHints(org.springframework.core.ResolvableType actualType, org.springframework.core.ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response)
HttpMessageDecoder
.