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:
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 booleanisReadable(@NonNull io.micronaut.core.type.Argument<T> type, @Nullable MediaType mediaType) Is the type readable.default Tread(@NonNull io.micronaut.core.type.Argument<T> type, @Nullable MediaType mediaType, @NonNull io.micronaut.core.type.Headers httpHeaders, @NonNull io.micronaut.core.io.buffer.ByteBuffer<?> byteBuffer) Reads an object from the given byte buffer.read(@NonNull io.micronaut.core.type.Argument<T> type, @Nullable MediaType mediaType, @NonNull io.micronaut.core.type.Headers httpHeaders, @NonNull InputStream inputStream) Reads an object from the given byte buffer.
-
Method Details
-
isReadable
default boolean isReadable(@NonNull @NonNull io.micronaut.core.type.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 io.micronaut.core.type.Argument<T> type, @Nullable @Nullable MediaType mediaType, @NonNull @NonNull io.micronaut.core.type.Headers httpHeaders, @NonNull @NonNull io.micronaut.core.io.buffer.ByteBuffer<?> byteBuffer) throws CodecException Reads an object from the given byte buffer.- Parameters:
type- The type being decoded.mediaType- The media type, can benullhttpHeaders- 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 io.micronaut.core.type.Argument<T> type, @Nullable @Nullable MediaType mediaType, @NonNull @NonNull io.micronaut.core.type.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 benullhttpHeaders- The HTTP headersinputStream- The input stream- Returns:
- The read object or
null - Throws:
CodecException- If an error occurs decoding
-