@API(status=STABLE) public final class JsonHttpLogFormatter extends Object implements HttpLogFormatter
HttpLogFormatter that produces JSON objects. It can be augmented with composition:
public class CustomsFormatter implements HttpLogFormatter {
private final JsonHttpLogFormatter delegate;
public CustomsFormatter(final ObjectMapper mapper) {
this.delegate = new JsonHttpLogFormatter(mapper);
}
public String format(final Precorrelation<HttpRequest> precorrelation) throws IOException {
Map<String, Object> request = delegate.prepare(precorrelation);
// TODO modify request here
return delegate.format(request);
}
public String format(final Correlation<HttpRequest, HttpResponse> correlation) throws IOException {
Map<String, Object> response = delegate.prepare(correlation);
// TODO modify response here
return delegate.format(response);
}
}
| Constructor and Description |
|---|
JsonHttpLogFormatter() |
JsonHttpLogFormatter(com.fasterxml.jackson.databind.ObjectMapper mapper) |
| Modifier and Type | Method and Description |
|---|---|
String |
format(Correlation<HttpRequest,HttpResponse> correlation) |
String |
format(Map<String,Object> content)
Renders properties of an HTTP message into a JSON string.
|
String |
format(Precorrelation<HttpRequest> precorrelation) |
Map<String,Object> |
prepare(Correlation<HttpRequest,HttpResponse> correlation)
Produces a map of individual properties from an HTTP response.
|
Map<String,Object> |
prepare(Precorrelation<HttpRequest> precorrelation)
Produces a map of individual properties from an HTTP request.
|
public JsonHttpLogFormatter()
public JsonHttpLogFormatter(com.fasterxml.jackson.databind.ObjectMapper mapper)
public String format(Precorrelation<HttpRequest> precorrelation) throws IOException
format in interface HttpLogFormatterIOException@API(status=EXPERIMENTAL) public Map<String,Object> prepare(Precorrelation<HttpRequest> precorrelation) throws IOException
precorrelation - the request correlationIOException - if reading body failsprepare(Correlation),
format(Map),
DefaultHttpLogFormatter.prepare(Precorrelation)public String format(Correlation<HttpRequest,HttpResponse> correlation) throws IOException
format in interface HttpLogFormatterIOException@API(status=EXPERIMENTAL) public Map<String,Object> prepare(Correlation<HttpRequest,HttpResponse> correlation) throws IOException
correlation - the response correlationIOException - if reading body failsprepare(Correlation),
format(Map),
DefaultHttpLogFormatter.prepare(Correlation)@API(status=EXPERIMENTAL) public String format(Map<String,Object> content) throws IOException
content - individual parts of an HTTP messageIOException - if writing JSON output failsprepare(Precorrelation),
prepare(Correlation),
DefaultHttpLogFormatter.format(List)Copyright © 2015–2018 Zalando SE. All rights reserved.