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,- PartEventHttpMessageWriter,- PartHttpMessageWriter,- 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 an ReactiveHttpOutputMessage.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Arjen Poutsma, Sebastien Deleuze
- 
Method SummaryModifier and TypeMethodDescriptionbooleancanWrite(ResolvableType elementType, MediaType mediaType) Whether the given object type is supported by this writer.Return the list of media types supported by this Writer.getWritableMediaTypes(ResolvableType elementType) Return the list of media types supported by this Writer for the given type of element.default reactor.core.publisher.Mono<Void>write(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(Publisher<? extends T> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) Write a given stream of object to the output message.
- 
Method Details- 
getWritableMediaTypesReturn the list of media types supported by this Writer. The list may not apply to every possible target element type and calls to this method should typically be guarded viacanWrite(elementType, null). The list may also exclude media types supported only for a specific element type. Alternatively, usegetWritableMediaTypes(ResolvableType)for a more precise list.- Returns:
- the general list of supported media types
 
- 
getWritableMediaTypesReturn the list of media types supported by this Writer for the given type of element. This list may differ fromgetWritableMediaTypes()if the Writer doesn't support the element type, or if it supports it only for a subset of media types.- Parameters:
- elementType- the type of element to encode
- Returns:
- the list of media types supported for the given class
- Since:
- 5.3.4
 
- 
canWriteWhether the given object type is supported by this writer.- Parameters:
- elementType- the type of object to check
- mediaType- the media type for the write (possibly- null)
- Returns:
- trueif writable,- falseotherwise
 
- 
writereactor.core.publisher.Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) Write a given stream of object to the output message.- Parameters:
- inputStream- the objects to write
- elementType- the type of objects in the stream which must have been previously checked via- canWrite(ResolvableType, MediaType)
- mediaType- the content type for the write (possibly- nullto indicate that the default content type of the writer must be used)
- message- the message to write to
- hints- additional information about how to encode and write
- Returns:
- indicates completion or error
 
- 
writedefault reactor.core.publisher.Mono<Void> write(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, the- MethodParametercan be accessed via- ResolvableType.getSource().
- elementType- the type of Objects in the input stream
- mediaType- the content type to use (possibly- nullindicating the default content type of the writer should be used)
- request- the current request
- response- the current response
- Returns:
- a Monothat indicates completion of writing or error
 
 
-