-
Notifications
You must be signed in to change notification settings - Fork 260
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
Allow using multiple strategies for multiple set of paths #1875
Labels
Comments
I don't think that needs to be part of the core itself. If I were you, I'd
just implement my own strategy that internally keeps pairs of Predicates
and strategies to delegate to. Within each method you find the relevant
strategy to delegate to.
…On Mon, Jul 29, 2024, 13:00 Peyman ***@***.***> wrote:
Detailed Description
Allowing multiple strategies to work alongside each other for different
situations. For example one strategy to work for a set of paths, conditions
and/or filters or excluded, while also a different set of paths
We have a requirement to log request and response for certain paths
regardless of the status of the response. So I use include to log these
paths by using the default strategy. However, there are some paths which
doesn't need to be logged unless an error happens. In which case we need to
see what was the request body or param that lead to this error.
I know status-at-least or body-only-if-status-at-least exist but there's
no way to have both the default and one of the two mentioned strategies
together.
Context
I guess the
Possible Implementation Your Environment
- Version used:
- Link to your project:
—
Reply to this email directly, view it on GitHub
<#1875>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADI7HO3EPS4OKQPLJ5JMHDZOYOEVAVCNFSM6AAAAABLUA5FOGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZTKMJQG4YDKOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@whiskeysierra How would I approach your suggestion? Could you give me a rough example? By the way I guess it doesn't have to be a new strategy. It could be a new kind of Predicate which accepts minimum status as parameter. predicate:
include:
- path: /test/logged
methods:
- POST
min-status: 400 |
You should take a look at
https://github.com/zalando/logbook?tab=readme-ov-file#strategy and
https://github.com/zalando/logbook/tree/main?tab=readme-ov-file#spring-boot-starter.
The idea is to implement a custom `Strategy` in code and when you register
that as a Spring bean, it will be used, rather than the default one.
Your proposed snippet there wouldn't solve your problem. You'd need
multiple predicates/strategies which aren't supported. Also, predicates
only have access to the request which means you can't test on the response
status. That's why strategy exists in the first place. Logbook's design
goal is to solve the 80% case out of the box (spring boot starter + yaml
config) and enable the other 20% to do it themselves (implement `Strategy`
interface directly).
…On Mon, Jul 29, 2024 at 4:37 PM Peyman ***@***.***> wrote:
@whiskeysierra <https://github.com/whiskeysierra> How would I approach
your suggestion? Could you give me a rough example?
By the way I guess it doesn't have to be a new strategy. It could be a new
kind of Predicate which accepts minimum status as parameter.
Something like this:
predicate:
include:
- path: /test/logged
methods:
- POST
min-status: 400
—
Reply to this email directly, view it on GitHub
<#1875 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADI7HMVVSSO3JUUJ5IVJVLZOZHQ5AVCNFSM6AAAAABLUA5FOGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJWGEYTQOJXGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Detailed Description
Allowing multiple strategies to work alongside each other for different situations. For example one strategy to work for a set of paths, conditions and/or filters, while having another strategy for different paths and conditions.
Context
We have a requirement to log request and response for certain paths regardless of the status of the response. So I use
include
to log these paths by using the default strategy. However, there are some paths which doesn't need to be logged unless an error happens. In which case we need to see what was the request body or param that lead to this error.I know
status-at-least
orbody-only-if-status-at-least
exist but there's no way to have both the default and one of the two mentioned strategies together. I tried to work this out with filters and other configs but had no success.Your Environment
logbook-spring-boot-webflux-autoconfigure
with Spring WebFluxThe text was updated successfully, but these errors were encountered: