Interface WebResponseBody

All Superinterfaces:
ResponseBody

public interface WebResponseBody extends ResponseBody

A response body with payload encoding support.

Implementors should rely on MediaTypeConverter to encode a payload based on the content type of the response.

If no content-type header is specified in the response when encoding the payload, implementors may use the definition of the route serving the resource and especially the produced media type when specified to determine the converter to use.

Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Method Details

    • transform

      Description copied from interface: ResponseBody

      Transforms the payload publisher.

      This can be used in an exchange interceptor in order to decorate response data publisher.

      Specified by:
      transform in interface ResponseBody
      Parameters:
      transformer - a request payload publisher transformer
      Returns:
      the response body
    • before

      WebResponseBody before(Mono<Void> before)
      Description copied from interface: ResponseBody

      Transforms the payload publisher to subscribe to the specified publisher before subscribing to the payload publisher.

      This basically allows to perform actions before the response is actually sent.

      Specified by:
      before in interface ResponseBody
      Parameters:
      before - the publisher to subscribe before the response body publisher
      Returns:
      the response body
    • after

      WebResponseBody after(Mono<Void> after)
      Description copied from interface: ResponseBody

      Transforms the payload publisher to subscribe to the specified publisher after payload publisher completion.

      This basically allows to perform actions after the response body has been sent.

      Specified by:
      after in interface ResponseBody
      Parameters:
      after - the publisher to subscribe before the response body publisher
      Returns:
      the response body
    • encoder

      <T> OutboundDataEncoder<T> encoder()

      Returns an encoder to encode a payload based on the content type of the request.

      Type Parameters:
      T - the type to encode
      Returns:
      an encoder
    • encoder

      <T> OutboundDataEncoder<T> encoder(Class<T> type)

      Returns an encoder to encode a payload of the specified type based on the content type of the request.

      Type Parameters:
      T - the type to encode
      Parameters:
      type - a class of T
      Returns:
      an encoder
    • encoder

      <T> OutboundDataEncoder<T> encoder(Type type)

      Returns an encoder to encode a payload of the specified type based on the content type of the request.

      Type Parameters:
      T - the type to encode
      Parameters:
      type - the type to encode
      Returns:
      an encoder
    • sseEncoder

      <T> WebResponseBody.SseEncoder<T> sseEncoder(String mediaType)

      Returns a server-sent events encoder to encode event's data in the specified media type.

      Type Parameters:
      T - the type to encode
      Parameters:
      mediaType - the target media type
      Returns:
      a SSE encoder
    • sseEncoder

      <T> WebResponseBody.SseEncoder<T> sseEncoder(String mediaType, Class<T> type)

      Returns a server-sent events encoder to encode event's data of the specified type in the specified media type.

      Type Parameters:
      T - the type to encode
      Parameters:
      mediaType - the target media type
      type - a class of T
      Returns:
      a SSE encoder
    • sseEncoder

      <T> WebResponseBody.SseEncoder<T> sseEncoder(String mediaType, Type type)

      Returns a server-sent events encoder to encode event's data of the specified type in the specified media type.

      Type Parameters:
      T - the type to encode
      Parameters:
      mediaType - the target media type
      type - the type to encode
      Returns:
      a SSE encoder