Interface InterceptableExchange<A extends ExchangeContext>
- Type Parameters:
A
- the type of the exchange context
- All Superinterfaces:
BaseExchange<A,
InterceptableRequest, InterceptableResponse>
An interceptable exchange is created in order to apply the exchange interception logic before sending the request.
It exposes a InterceptableRequest
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 interceptable 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 InterceptableResponse
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 InterceptableResponseBody
in order to decorate the response body that will be received from the endpoint.
When the response is received from the endpoint the interceptable 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 InterceptableResponseBody.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 TypeMethodDescriptionrequest()
Returns an interceptable request which proxies the original request and allows to override values before it is sent to the endpoint.response()
Returns an interceptable 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
InterceptableRequest request()Returns an interceptable 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 interceptable request becomes a proxy for the sent request and it can no longer be used to modify request data.
- Specified by:
request
in interfaceBaseExchange<A extends ExchangeContext,
InterceptableRequest, InterceptableResponse> - Returns:
- the request part
-
response
InterceptableResponse response()Returns an interceptable 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 interceptable response becomes a proxy for the received response and it can no longer be used to modify response data.
- Specified by:
response
in interfaceBaseExchange<A extends ExchangeContext,
InterceptableRequest, InterceptableResponse> - Returns:
- the response part
-