Interface InterceptedExchange<A extends ExchangeContext>

Type Parameters:
A - the type of the exchange context
All Superinterfaces:
BaseExchange<A,InterceptedRequest,InterceptedResponse>
All Known Subinterfaces:
InterceptedWebExchange<A>

public interface InterceptedExchange<A extends ExchangeContext> extends BaseExchange<A,InterceptedRequest,InterceptedResponse>

An intercepted exchange is created in order to apply the exchange interception logic before sending the request.

It exposes a InterceptedRequest which acts as a proxy for the original request allowing an interceptor to modify the original request.

When the request is sent to the endpoint, the intercepted request becomes a proxy for the sent request and an IllegalStateException shall be thrown when trying to set the method, path, the authority, headers or transform the body.

It exposes a InterceptedResponse which allows an interceptor to provide a complete response when returning an empty exchange Mono to prevent the request from being sent. A response body transformer can be specified on the InterceptedResponseBody in order to decorate the response body that will be received from the endpoint.

When the response is received from the endpoint the intercepted response becomes a proxy for the received response and an IllegalStateException shall be thrown when trying to set headers or the body of the response. It might still be possible to invoke InterceptedResponseBody.transform(java.util.function.Function) in order to transform the body assuming it hasn't been subscribed yet otherwise an IllegalStateException is thrown.

Since:
1.6
Author:
Jeremy Kuhn
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an intercepted request which proxies the original request and allows to override values before it is sent to the endpoint.
    Returns an intercepted response which allows to provide a complete response when bypassing the sending of the request or transform the actual response body.

    Methods inherited from interface io.inverno.mod.http.base.BaseExchange

    context, getCancelCause, getProtocol, reset, reset
  • Method Details

    • request

      Returns an intercepted request which proxies the original request and allows to override values before it is sent to the endpoint.

      Once the request is sent to the endpoint, the intercepted request becomes a proxy for the sent request and it can no longer be used to modify request data.

      Specified by:
      request in interface BaseExchange<A extends ExchangeContext,InterceptedRequest,InterceptedResponse>
      Returns:
      the request part
    • response

      Returns an intercepted response which allows to provide a complete response when bypassing the sending of the request or transform the actual response body.

      Once a response is received from the endpoint the intercepted response becomes a proxy for the received response and it can no longer be used to modify response data.

      Specified by:
      response in interface BaseExchange<A extends ExchangeContext,InterceptedRequest,InterceptedResponse>
      Returns:
      the response part