@API(status=STABLE)
public interface Strategy
Logbook integrations and the Sink. The lifecycle of a request-response
pair will invoke methods in the following order:
process(HttpRequest)write(Precorrelation, HttpRequest, Sink)process(HttpRequest, HttpResponse)write(Correlation, HttpRequest, HttpResponse, Sink)At each of those points in time different options are available, e.g. to defer logging, apply conditions or even modify something. Strategy pattern
| Modifier and Type | Method and Description |
|---|---|
default HttpRequest |
process(HttpRequest request)
This method is being called right before the request body is being buffered.
|
default HttpResponse |
process(HttpRequest request,
HttpResponse response)
This method is being called right before the response body is being buffered.
|
default void |
write(Correlation correlation,
HttpRequest request,
HttpResponse response,
Sink sink)
This method is being called right after the response body was buffered.
|
default void |
write(Precorrelation precorrelation,
HttpRequest request,
Sink sink)
This method is being called right after the response body was buffered.
|
default HttpRequest process(HttpRequest request) throws IOException
Defaults to HttpRequest.withBody().
request - the current requestIOException - see HttpRequest.withBody()HttpRequest.withBody(),
HttpRequest.withoutBody()default void write(Precorrelation precorrelation, HttpRequest request, Sink sink) throws IOException
Options include but are not limited to:
Defaults to delegating to Sink.write(Precorrelation, HttpRequest).
precorrelation - a preliminary correlation which provides an id to correlate request
and response laterrequest - the current requestsink - the sink to write to, if neededIOException - see Sink.write(Precorrelation, HttpRequest)Sink.write(Precorrelation, HttpRequest)default HttpResponse process(HttpRequest request, HttpResponse response) throws IOException
request.
Defaults to HttpResponse.withBody().
request - the current requestresponse - the current responseIOException - see HttpResponse.withBody()HttpResponse.withBody(),
HttpResponse.withoutBody()default void write(Correlation correlation, HttpRequest request, HttpResponse response, Sink sink) throws IOException
Options include but are not limited to:
Defaults to delegating to Sink.write(Correlation, HttpRequest, HttpResponse).
correlation - a correlation which provides and id (as well as a duration) to correlate request and response
laterrequest - the current requestresponse - the current responsesink - the sink to write to, if neededIOException - see Sink.write(Correlation, HttpRequest, HttpResponse)Sink.write(Correlation, HttpRequest, HttpResponse),
Sink.writeBoth(Correlation, HttpRequest, HttpResponse)Copyright © 2015–2021 Zalando SE. All rights reserved.