T
- the type of objects in the decoded output streampublic class DecoderHttpMessageReader<T> extends 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(Decoder<T> decoder)
Create an instance wrapping the given
Decoder . |
Modifier and Type | Method and Description |
---|---|
boolean |
canRead(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 . |
Decoder<T> |
getDecoder()
Return the
Decoder of this reader. |
List<MediaType> |
getReadableMediaTypes()
Return the
MediaType 's that this reader supports. |
protected Map<String,Object> |
getReadHints(ResolvableType actualType,
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(ResolvableType elementType,
ReactiveHttpInputMessage message,
Map<String,Object> hints)
Read from the input message and encode to a stream of objects.
|
reactor.core.publisher.Flux<T> |
read(ResolvableType actualType,
ResolvableType elementType,
ServerHttpRequest request,
ServerHttpResponse response,
Map<String,Object> hints)
Server-side only alternative to
HttpMessageReader.read(ResolvableType, ReactiveHttpInputMessage, Map)
with additional context available. |
reactor.core.publisher.Mono<T> |
readMono(ResolvableType elementType,
ReactiveHttpInputMessage message,
Map<String,Object> hints)
Read from the input message and encode to a single object.
|
reactor.core.publisher.Mono<T> |
readMono(ResolvableType actualType,
ResolvableType elementType,
ServerHttpRequest request,
ServerHttpResponse response,
Map<String,Object> hints)
Server-side only alternative to
HttpMessageReader.readMono(ResolvableType, ReactiveHttpInputMessage, Map)
with additional, context available. |
public List<MediaType> getReadableMediaTypes()
HttpMessageReader
MediaType
's that this reader supports.getReadableMediaTypes
in interface HttpMessageReader<T>
public boolean canRead(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(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,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(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,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(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,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(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,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 Map<String,Object> getReadHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response)
HttpMessageDecoder
.