-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include a list of paths in the logging process #234
Comments
Using You can craft your own helper methods: @SafeVarargs
public static <T extends BaseHttpMessage> Predicate<T> include(final Predicate<T>... predicates) {
return include(Arrays.asList(predicates));
}
public static <T extends BaseHttpMessage> Predicate<T> include(final Collection<Predicate<T>> predicates) {
return predicates.stream()
.reduce(Predicate::or)
.orElse($ -> false);
} Which would allow you to write: Logbook.builder()
.condition(include(
requestTo("/pathOne"),
requestTo("/pathTwo"),
requestTo("/pathThree")))
.build(); Please not that the most important part of this the implementation of As you can see, I'm making use of static imports which shorten it some more. If you're lucky and all of your paths actually share the same prefix you could use |
I can derive two potential changes for logbook from this:
@lukasniemeier-zalando @AlexanderYastrebov What do you think? |
Why Logbook.builder()
.condition(
requestTo("/a")
.or(requestTo("/b"))
.or(requestTo("/c"))
.or(contentType("whatever")))
.build(); will not work for this case? |
That would of course work. I always forget to use |
Problem solved? :) |
@Nisreen123 Is it? |
@whiskeysierra |
.condition(include(includedPaths.stream().map(Conditions::requestTo).collect(toList()))) |
how can we add a condition to include a list of paths, i Know i can use
.condition(Conditions.requestTo("/pathOne"))
.condition(Conditions.requestTo("/pathTwo"))
.condition(Conditions.requestTo("/pathThree")), but is there any better approach?
The text was updated successfully, but these errors were encountered: