接口 HttpMessageReader<T>
- 类型参数:
T- the type of objects in the decoded output stream
- 所有已知实现类:
DecoderHttpMessageReader,FormHttpMessageReader,MultipartHttpMessageReader,ResourceHttpMessageReader,ServerSentEventHttpMessageReader,SynchronossPartHttpMessageReader
public interface HttpMessageReader<T>
Strategy for reading from aReactiveHttpInputMessageand decoding the stream of bytes to Objects of type<T>.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Arjen Poutsma, Sebastien Deleuze
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 booleancanRead(ResolvableType elementType, MediaType mediaType)Whether the given object type is supported by this reader.List<MediaType>getReadableMediaTypes()Return theMediaType's that this reader supports.default reactor.core.publisher.Flux<T>read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)Server-side only alternative toread(ResolvableType, ReactiveHttpInputMessage, Map)with additional context available.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.default reactor.core.publisher.Mono<T>readMono(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)Server-side only alternative toreadMono(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.
方法详细资料
getReadableMediaTypes
List<MediaType> getReadableMediaTypes()
Return theMediaType's that this reader supports.
canRead
boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType)
Whether the given object type is supported by this reader.- 参数:
elementType- the type of object to checkmediaType- the media type for the read (possiblynull)- 返回:
trueif readable,falseotherwise
read
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.- 参数:
elementType- the type of objects in the stream which must have been previously checked viacanRead(ResolvableType, MediaType)message- the message to read fromhints- additional information about how to read and decode the input- 返回:
- the decoded stream of elements
readMono
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.- 参数:
elementType- the type of objects in the stream which must have been previously checked viacanRead(ResolvableType, MediaType)message- the message to read fromhints- additional information about how to read and decode the input- 返回:
- the decoded object
read
default reactor.core.publisher.Flux<T> read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
Server-side only alternative toread(ResolvableType, ReactiveHttpInputMessage, Map)with additional context available.- 参数:
actualType- the actual type of the target method parameter; for annotated controllers, theMethodParametercan be accessed viaResolvableType.getSource().elementType- the type of Objects in the output streamrequest- the current requestresponse- the current responsehints- additional information about how to read the body- 返回:
- the decoded stream of elements
readMono
default reactor.core.publisher.Mono<T> readMono(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
Server-side only alternative toreadMono(ResolvableType, ReactiveHttpInputMessage, Map)with additional, context available.- 参数:
actualType- the actual type of the target method parameter; for annotated controllers, theMethodParametercan be accessed viaResolvableType.getSource().elementType- the type of Objects in the output streamrequest- the current requestresponse- the current responsehints- additional information about how to read the body- 返回:
- the decoded stream of elements