Package io.micronaut.http.body
Interface MessageBodyReader<T>
- Type Parameters:
T
- The generic type.
- All Known Subinterfaces:
ChunkedMessageBodyReader<T>
,MessageBodyHandler<T>
,TypedMessageBodyHandler<T>
,TypedMessageBodyReader<T>
- All Known Implementing Classes:
JsonMessageHandler
,NettyByteBufMessageBodyHandler
,NettyJsonHandler
,NettyJsonStreamHandler
,NettyWritableBodyWriter
,StringBodyReader
,TextPlainObjectBodyReader
,WritableBodyWriter
An interface that allows reading a message body from the client or the server.
Implementors can defined beans that are annotated with Consumes
to restrict the applicable content types.
Use Order
to specify the precedence of the reader with lower order corresponding to higher precedence.
- Since:
- 4.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Is the type readable.default T
read
(@NonNull Argument<T> type, @Nullable MediaType mediaType, @NonNull Headers httpHeaders, @NonNull ByteBuffer<?> byteBuffer) Reads an object from the given byte buffer.read
(@NonNull Argument<T> type, @Nullable MediaType mediaType, @NonNull Headers httpHeaders, @NonNull InputStream inputStream) Reads an object from the given byte buffer.
-
Method Details
-
isReadable
default boolean isReadable(@NonNull @NonNull Argument<T> type, @Nullable @Nullable MediaType mediaType) Is the type readable.- Parameters:
type
- The typemediaType
- The media type, can benull
- Returns:
- True if is readable
-
read
@Nullable default T read(@NonNull @NonNull Argument<T> type, @Nullable @Nullable MediaType mediaType, @NonNull @NonNull Headers httpHeaders, @NonNull @NonNull ByteBuffer<?> byteBuffer) throws CodecException Reads an object from the given byte buffer.- Parameters:
type
- The type being decoded.mediaType
- The media type, can benull
httpHeaders
- The HTTP headersbyteBuffer
- The byte buffer- Returns:
- The read object or
null
- Throws:
CodecException
- If an error occurs decoding
-
read
@Nullable T read(@NonNull @NonNull Argument<T> type, @Nullable @Nullable MediaType mediaType, @NonNull @NonNull Headers httpHeaders, @NonNull @NonNull InputStream inputStream) throws CodecException Reads an object from the given byte buffer.- Parameters:
type
- The type being decoded.mediaType
- The media type, can benull
httpHeaders
- The HTTP headersinputStream
- The input stream- Returns:
- The read object or
null
- Throws:
CodecException
- If an error occurs decoding
-