Class ByteBufRawMessageBodyHandler

java.lang.Object
io.micronaut.http.netty.body.ByteBufRawMessageBodyHandler
All Implemented Interfaces:
ChunkedMessageBodyReader<io.netty.buffer.ByteBuf>, MessageBodyHandler<io.netty.buffer.ByteBuf>, MessageBodyReader<io.netty.buffer.ByteBuf>, MessageBodyWriter<io.netty.buffer.ByteBuf>, RawMessageBodyHandler<io.netty.buffer.ByteBuf>

@Internal @Singleton @Bean(typed=RawMessageBodyHandler.class) public final class ByteBufRawMessageBodyHandler extends Object implements RawMessageBodyHandler<io.netty.buffer.ByteBuf>
Handler for netty ByteBuf.
Since:
4.0.0
Author:
Jonas Konrad
  • Constructor Details

    • ByteBufRawMessageBodyHandler

      public ByteBufRawMessageBodyHandler()
  • Method Details

    • readChunked

      public Publisher<io.netty.buffer.ByteBuf> readChunked(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, Publisher<ByteBuffer<?>> input)
      Specified by:
      readChunked in interface ChunkedMessageBodyReader<io.netty.buffer.ByteBuf>
    • read

      public io.netty.buffer.ByteBuf read(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, ByteBuffer<?> byteBuffer) throws CodecException
      Description copied from interface: MessageBodyReader
      Reads an object from the given byte buffer.
      Specified by:
      read in interface MessageBodyReader<io.netty.buffer.ByteBuf>
      Parameters:
      type - The type being decoded.
      mediaType - The media type, can be null
      httpHeaders - The HTTP headers
      byteBuffer - The byte buffer
      Returns:
      The read object or null
      Throws:
      CodecException - If an error occurs decoding
    • read

      public io.netty.buffer.ByteBuf read(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, InputStream inputStream) throws CodecException
      Description copied from interface: MessageBodyReader
      Reads an object from the given byte buffer.
      Specified by:
      read in interface MessageBodyReader<io.netty.buffer.ByteBuf>
      Parameters:
      type - The type being decoded.
      mediaType - The media type, can be null
      httpHeaders - The HTTP headers
      inputStream - The input stream
      Returns:
      The read object or null
      Throws:
      CodecException - If an error occurs decoding
    • writeTo

      public void writeTo(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, io.netty.buffer.ByteBuf object, MutableHeaders outgoingHeaders, OutputStream outputStream) throws CodecException
      Description copied from interface: MessageBodyWriter
      Writes an object to the given output stream.
      Specified by:
      writeTo in interface MessageBodyWriter<io.netty.buffer.ByteBuf>
      Parameters:
      type - The type
      mediaType - The media type
      object - The object to write
      outgoingHeaders - The HTTP headers
      outputStream - The output stream
      Throws:
      CodecException - If an error occurs decoding
    • writeTo

      public ByteBuffer<?> writeTo(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, io.netty.buffer.ByteBuf object, MutableHeaders outgoingHeaders, ByteBufferFactory<?,?> bufferFactory) throws CodecException
      Description copied from interface: MessageBodyWriter
      Writes an object to the given stream.
      Specified by:
      writeTo in interface MessageBodyWriter<io.netty.buffer.ByteBuf>
      Parameters:
      type - The type
      mediaType - The media type
      object - The object to write
      outgoingHeaders - The HTTP headers
      bufferFactory - A byte buffer factory
      Returns:
      The encoded byte buffer
      Throws:
      CodecException - If an error occurs decoding
    • getTypes

      public Collection<Class<io.netty.buffer.ByteBuf>> getTypes()
      Description copied from interface: RawMessageBodyHandler
      Supported types of this raw body handler. Exact match is used for reading. For writing, the match is covariant. For example, if this returns [String, CharSequence], then this raw handler will be used for reading types declared as exactly String or CharSequence, and will additionally be used for writing (but not reading) subtypes (e.g. StringBuilder).
      Specified by:
      getTypes in interface RawMessageBodyHandler<io.netty.buffer.ByteBuf>
      Returns:
      The supported types