Skip to content
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

Support reading the body multiple times in ReadBodyRoutePredicateFactory #3548

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

qnnn
Copy link
Contributor

@qnnn qnnn commented Oct 3, 2024

I noticed in the ReadBodyRoutePredicateFactory that it states "we do not try to read the request body multiple times." This seems to impact the logic of route matching. The reproducible route definitions are as follows(or see unit test):

.route(
        r -> r.order(-2).readBody(String.class, string -> false)
                .uri("http://127.0.0.1:8081"))
.route(
        // At this point, even if the body content can be converted to a map,
        // this assertion will not be hit.
        r -> r.order(-1).readBody(Map.class, map -> true)
                .uri("http://127.0.0.1:8081"))

If one route is not matched, it should not affect the matching of other routes. Additionally, we have placed the mutable request in the CACHED_SERVER_HTTP_REQUEST_DECORATOR_ATTR attribute, and we can continue to use it to address this.

@qnnn
Copy link
Contributor Author

qnnn commented Oct 3, 2024

A corresponding implementation has also been made in Gateway MVC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants