io.vertx.ext.web.codec

## Interface BodyCodec<T>

-     public interface BodyCodec<T>

  A codec for encoding and decoding HTTP bodies.
  Author:
    Julien Viet

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static BodyCodec<Buffer>` | `buffer()`
    `static <T> BodyCodec<T>` | `create(java.util.function.Function<Buffer,T> decode)` Create a codec that buffers the entire body and then apply the `decode` function and returns the result.
    `void` | `create(Handler<AsyncResult<BodyStream<T>>> handler)` Create the `BodyStream`.
    `static <U> BodyCodec<U>` | `json(Class<U> type)` Create and return a codec for Java objects encoded using Jackson mapper.
    `static BodyCodec<JsonArray>` | `jsonArray()`
    `static BodyCodec<JsonObject>` | `jsonObject()`
    `static BodyCodec<Void>` | `jsonStream(JsonParser parser)` A body codec that parse the response as a JSON stream.
    `static BodyCodec<Void>` | `none()`
    `static BodyCodec<Void>` | `pipe(WriteStream<Buffer> stream)` A body codec that pipes the body to a write stream.
    `static BodyCodec<Void>` | `pipe(WriteStream<Buffer> stream, boolean close)` A body codec that pipes the body to a write stream.
    `static BodyCodec<String>` | `string()`
    `static BodyCodec<String>` | `string(String encoding)` A codec for strings using a specific `encoding`.

- - ### Method Detail

    - #### string

          static BodyCodec<String> string()

      Returns:
        the UTF-8 string codec

    - #### string

          static BodyCodec<String> string(String encoding)

      A codec for strings using a specific `encoding`.
      Parameters:
        `encoding` - the encoding
      Returns:
        the codec

    - #### buffer

          static BodyCodec<Buffer> buffer()

      Returns:
        the `Buffer` codec

    - #### jsonObject

          static BodyCodec<JsonObject> jsonObject()

      Returns:
        the `JsonObject` codec

    - #### jsonArray

          static BodyCodec<JsonArray> jsonArray()

      Returns:
        the `JsonArray` codec

    - #### json

          static <U> BodyCodec<U> json(Class<U> type)

      Create and return a codec for Java objects encoded using Jackson mapper.
      Returns:
        a codec for mapping POJO to Json

    - #### none

          static BodyCodec<Void> none()

      Returns:
        a codec that simply discards the response

    - #### create

          static <T> BodyCodec<T> create(java.util.function.Function<Buffer,T> decode)

      Create a codec that buffers the entire body and then apply the `decode` function and returns the result.
      Parameters:
        `decode` - the decode function
      Returns:
        the created codec

    - #### pipe

          static BodyCodec<Void> pipe(WriteStream<Buffer> stream)

      A body codec that pipes the body to a write stream.

      Same as pipe(stream, true).
      Parameters:
        `stream` - the destination stream
      Returns:
        the body codec for a write stream

    - #### pipe

          static BodyCodec<Void> pipe(WriteStream<Buffer> stream,
                                      boolean close)

      A body codec that pipes the body to a write stream.
      Parameters:
        `stream` - the destination stream
        `close` - whether the destination stream should be closed
      Returns:
        the body codec for a write stream

    - #### jsonStream

          static BodyCodec<Void> jsonStream(JsonParser parser)

      A body codec that parse the response as a JSON stream.
      Parameters:
        `parser` - the non-null JSON parser to emits the JSON object. The parser must be configured for the stream. Not e that you need to keep a reference on the parser to retrieved the JSON events.
      Returns:
        the body codec for a write stream

    - #### create

          void create(Handler<AsyncResult<BodyStream<T>>> handler)

      Create the `BodyStream`.

      This method is usually called for creating the pump for the HTTP response and should not be called directly.

Copyright © 2021 Eclipse. All rights reserved.