public class ServerSentEventHttpMessageWriter extends Object implements HttpMessageWriter<Object>
ServerSentEvents and also plain
Objects which is the same as an ServerSentEvent with data
only.| Modifier and Type | Field and Description |
|---|---|
static String |
SSE_CONTENT_HINT
Server-Sent Events hint key expecting a
Boolean value which when set to true
will adapt the content in order to comply with Server-Sent Events recommendation. |
| Constructor and Description |
|---|
ServerSentEventHttpMessageWriter() |
ServerSentEventHttpMessageWriter(List<org.springframework.core.codec.Encoder<?>> dataEncoders) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canWrite(org.springframework.core.ResolvableType elementType,
MediaType mediaType)
Indicates whether the given class can be written by this converter.
|
List<MediaType> |
getWritableMediaTypes()
Return the list of
MediaType objects that can be written by this converter. |
reactor.core.publisher.Mono<Void> |
write(org.reactivestreams.Publisher<?> inputStream,
org.springframework.core.ResolvableType elementType,
MediaType mediaType,
ReactiveHttpOutputMessage outputMessage,
Map<String,Object> hints)
Write an given object to the given output message.
|
public static final String SSE_CONTENT_HINT
Boolean value which when set to true
will adapt the content in order to comply with Server-Sent Events recommendation.
For example, it will append "data:" after each line break with data encoders
supporting it.public ServerSentEventHttpMessageWriter()
public ServerSentEventHttpMessageWriter(List<org.springframework.core.codec.Encoder<?>> dataEncoders)
public boolean canWrite(org.springframework.core.ResolvableType elementType,
MediaType mediaType)
HttpMessageWritercanWrite in interface HttpMessageWriter<Object>elementType - the stream element type to test for writabilitymediaType - the media type to write, can be null if not specified.
Typically the value of an Accept header.true if writable; false otherwisepublic List<MediaType> getWritableMediaTypes()
HttpMessageWriterMediaType objects that can be written by this converter.getWritableMediaTypes in interface HttpMessageWriter<Object>public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<?> inputStream, org.springframework.core.ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, Map<String,Object> hints)
HttpMessageWriterwrite in interface HttpMessageWriter<Object>inputStream - the input stream to writeelementType - the stream element type to process. This type must have previously
been passed to the HttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType) canWrite} method of this interface, which must
have returned true.mediaType - the content type to use when writing, typically the value of an
Accept header. May be null to indicate that the default content
type of the converter must be used.outputMessage - the message to write tohints - additional information about how to writeMono that indicates completion or error