Package org.springframework.http.codec
Interface HttpMessageWriter<T>
- Type Parameters:
T
- the type of objects in the input stream
- All Known Implementing Classes:
EncoderHttpMessageWriter
,FormHttpMessageWriter
,MultipartHttpMessageWriter
,ProtobufHttpMessageWriter
,ResourceHttpMessageWriter
,ServerSentEventHttpMessageWriter
public interface HttpMessageWriter<T>
Strategy for encoding a stream of objects of type<T>
and writing the encoded stream of bytes to anReactiveHttpOutputMessage
.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Arjen Poutsma, Sebastien Deleuze
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canWrite(ResolvableType elementType, MediaType mediaType)
Whether the given object type is supported by this writer.List<MediaType>
getWritableMediaTypes()
Return theMediaType
's that this writer supports.default reactor.core.publisher.Mono<Void>
write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
Server-side only alternative towrite(Publisher, ResolvableType, MediaType, ReactiveHttpOutputMessage, Map)
with additional context available.reactor.core.publisher.Mono<Void>
write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
Write an given stream of object to the output message.
Method Detail
getWritableMediaTypes
List<MediaType> getWritableMediaTypes()
Return theMediaType
's that this writer supports.
canWrite
boolean canWrite(ResolvableType elementType, @Nullable MediaType mediaType)
Whether the given object type is supported by this writer.- Parameters:
elementType
- the type of object to checkmediaType
- the media type for the write (possiblynull
)- Returns:
true
if writable,false
otherwise
write
reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
Write an given stream of object to the output message.- Parameters:
inputStream
- the objects to writeelementType
- the type of objects in the stream which must have been previously checked viacanWrite(ResolvableType, MediaType)
mediaType
- the content type for the write (possiblynull
to indicate that the default content type of the writer must be used)message
- the message to write tohints
- additional information about how to encode and write- Returns:
- indicates completion or error
write
default reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
Server-side only alternative towrite(Publisher, ResolvableType, MediaType, ReactiveHttpOutputMessage, Map)
with additional context available.- Parameters:
actualType
- the actual return type of the method that returned the value; for annotated controllers, theMethodParameter
can be accessed viaResolvableType.getSource()
.elementType
- the type of Objects in the input streammediaType
- the content type to use (possiblynull
indicating the default content type of the writer should be used)request
- the current requestresponse
- the current response- Returns:
- a
Mono
that indicates completion of writing or error