Class ProtobufHttpMessageWriter
- java.lang.Object
- org.springframework.http.codec.EncoderHttpMessageWriter<com.google.protobuf.Message>
- org.springframework.http.codec.protobuf.ProtobufHttpMessageWriter
- All Implemented Interfaces:
HttpMessageWriter<com.google.protobuf.Message>
public class ProtobufHttpMessageWriter extends EncoderHttpMessageWriter<com.google.protobuf.Message>
HttpMessageWriter
that can write a protobufMessage
and addsX-Protobuf-Schema
,X-Protobuf-Message
headers and adelimited=true
parameter is added to the content type if a flux is serialized.For
HttpMessageReader
, just usenew DecoderHttpMessageReader(new ProtobufDecoder())
.- Since:
- 5.1
- Author:
- S茅bastien Deleuze
- See Also:
ProtobufEncoder
Constructor Summary
Constructors Constructor Description ProtobufHttpMessageWriter()
Create a newProtobufHttpMessageWriter
with a defaultProtobufEncoder
.ProtobufHttpMessageWriter(Encoder<com.google.protobuf.Message> encoder)
Create a newProtobufHttpMessageWriter
with the given encoder.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description reactor.core.publisher.Mono<Void>
write(org.reactivestreams.Publisher<? extends com.google.protobuf.Message> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
Write an given stream of object to the output message.Methods inherited from class org.springframework.http.codec.EncoderHttpMessageWriter
canWrite, getEncoder, getWritableMediaTypes, getWriteHints, write
Constructor Detail
ProtobufHttpMessageWriter
public ProtobufHttpMessageWriter()
Create a newProtobufHttpMessageWriter
with a defaultProtobufEncoder
.
ProtobufHttpMessageWriter
public ProtobufHttpMessageWriter(Encoder<com.google.protobuf.Message> encoder)
Create a newProtobufHttpMessageWriter
with the given encoder.- Parameters:
encoder
- the Protobuf message encoder to use
Method Detail
write
public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends com.google.protobuf.Message> inputStream, ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
Description copied from interface:HttpMessageWriter
Write an given stream of object to the output message.- Specified by:
write
in interfaceHttpMessageWriter<com.google.protobuf.Message>
- Overrides:
write
in classEncoderHttpMessageWriter<com.google.protobuf.Message>
- Parameters:
inputStream
- the objects to writeelementType
- the type of objects in the stream which must have been previously checked viaHttpMessageWriter.canWrite(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