Skip to content

Commit

Permalink
add documentation for chain examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-amiaud committed Jun 24, 2021
1 parent 0487e8d commit 4b0ddc8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions plume-admin-api-log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,33 @@ new OkHttpLoggerInterceptor(
)
```

Example to chain predicates that will not log POST and PUT requests, and endpoints that start with `/api/orders`
```java
new OkHttpLoggerInterceptor(
"Github",
logApiService,
RequestPredicate.alwaysTrue()
.filterMethod(HttpMethod.POST)
.filterMethod(HttpMethod.PUT)
.filterEndpointStartsWith("api/order")
)
```

Example to chain transformers to log custom api names, and only the first 1024 chars of the request/response, only for requests with 'Authorization' Header and that is HTTPS
```java
new OkHttpLoggerInterceptor(
"Github",
logApiService,
LogEntryTransformer.limitBodySizeTransformer(1024)
.andApply((request, response, logInterceptApiBean) -> {
String newName = logInterceptApiBean.getApiName() + "-HTTPS-1024chars";
logInterceptApiBean.setApiName(newName);
return logInterceptApiBean;
})
.applyOnlyToRequests(request -> request.isHttps() && request.header("Authorization") != null)
)
```

`LogEntryTransformer` and `RequestPredicate` are interfaces, so the possibilities of transforming and filtering are prettry much endless.

Configuration
Expand Down

0 comments on commit 4b0ddc8

Please sign in to comment.