Class YamlMessageHandler<T>
java.lang.Object
io.micronaut.serde.yaml.body.YamlMessageHandler<T>
- Type Parameters:
T- The type to read/write
- All Implemented Interfaces:
io.micronaut.http.body.MessageBodyHandler<T>, io.micronaut.http.body.MessageBodyReader<T>, io.micronaut.http.body.MessageBodyWriter<T>, io.micronaut.http.body.ResponseBodyWriter<T>
@Order(10)
@Singleton
@Requires(classes=io.micronaut.http.body.MessageBodyHandler.class)
@ProducesYaml
@ConsumesYaml
public final class YamlMessageHandler<T>
extends Object
implements io.micronaut.http.body.MessageBodyHandler<T>, io.micronaut.http.body.ResponseBodyWriter<T>
HTTP message body handler for YAML using Micronaut Serialization.
Handles application/yaml and application/x-yaml request and response bodies
with the YamlObjectMapper. The handler is only loaded when Micronaut HTTP is on the
classpath.
- Since:
- 3.2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceAConsumesannotation for YAML.static @interfaceAProducesannotation for YAML. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPrefer JSON handlers for generic negotiation; YAML is selected by media type. -
Constructor Summary
ConstructorsConstructorDescriptionYamlMessageHandler(YamlObjectMapper yamlObjectMapper) Creates a handler that delegates YAML mapping to the given mapper. -
Method Summary
Modifier and TypeMethodDescriptionReturns the YAML mapper used by this handler.booleanisReadable(io.micronaut.core.type.Argument<T> type, @Nullable io.micronaut.http.MediaType mediaType) booleanisWriteable(io.micronaut.core.type.Argument<T> type, @Nullable io.micronaut.http.MediaType mediaType) @Nullable Tread(io.micronaut.core.type.Argument<T> type, @Nullable io.micronaut.http.MediaType mediaType, io.micronaut.core.type.Headers httpHeaders, io.micronaut.core.io.buffer.ByteBuffer<?> byteBuffer) @Nullable Tread(io.micronaut.core.type.Argument<T> type, @Nullable io.micronaut.http.MediaType mediaType, io.micronaut.core.type.Headers httpHeaders, InputStream inputStream) io.micronaut.http.body.CloseableByteBodywritePiece(io.micronaut.http.body.ByteBodyFactory bodyFactory, io.micronaut.http.HttpRequest<?> request, io.micronaut.http.HttpResponse<?> response, io.micronaut.core.type.Argument<T> type, io.micronaut.http.MediaType mediaType, T object) voidwriteTo(io.micronaut.core.type.Argument<T> type, @Nullable io.micronaut.http.MediaType mediaType, T object, io.micronaut.core.type.MutableHeaders outgoingHeaders, OutputStream outputStream) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, isBlocking, writeToMethods inherited from interface io.micronaut.http.body.ResponseBodyWriter
write
-
Field Details
-
ORDER
public static final int ORDERPrefer JSON handlers for generic negotiation; YAML is selected by media type.- See Also:
-
-
Constructor Details
-
YamlMessageHandler
Creates a handler that delegates YAML mapping to the given mapper.- Parameters:
yamlObjectMapper- The YAML object mapper
-
-
Method Details
-
getYamlObjectMapper
Returns the YAML mapper used by this handler.- Returns:
- The mapper
-
isReadable
-
isWriteable
-
read
public @Nullable T read(io.micronaut.core.type.Argument<T> type, @Nullable io.micronaut.http.MediaType mediaType, io.micronaut.core.type.Headers httpHeaders, io.micronaut.core.io.buffer.ByteBuffer<?> byteBuffer) throws io.micronaut.http.codec.CodecException - Specified by:
readin interfaceio.micronaut.http.body.MessageBodyReader<T>- Throws:
io.micronaut.http.codec.CodecException
-
read
public @Nullable T read(io.micronaut.core.type.Argument<T> type, @Nullable io.micronaut.http.MediaType mediaType, io.micronaut.core.type.Headers httpHeaders, InputStream inputStream) throws io.micronaut.http.codec.CodecException - Specified by:
readin interfaceio.micronaut.http.body.MessageBodyReader<T>- Throws:
io.micronaut.http.codec.CodecException
-
writeTo
public void writeTo(io.micronaut.core.type.Argument<T> type, @Nullable io.micronaut.http.MediaType mediaType, T object, io.micronaut.core.type.MutableHeaders outgoingHeaders, OutputStream outputStream) throws io.micronaut.http.codec.CodecException - Specified by:
writeToin interfaceio.micronaut.http.body.MessageBodyWriter<T>- Throws:
io.micronaut.http.codec.CodecException
-
writePiece
public io.micronaut.http.body.CloseableByteBody writePiece(io.micronaut.http.body.ByteBodyFactory bodyFactory, io.micronaut.http.HttpRequest<?> request, io.micronaut.http.HttpResponse<?> response, io.micronaut.core.type.Argument<T> type, io.micronaut.http.MediaType mediaType, T object) throws io.micronaut.http.codec.CodecException - Specified by:
writePiecein interfaceio.micronaut.http.body.ResponseBodyWriter<T>- Throws:
io.micronaut.http.codec.CodecException
-