spring-cloud / spring-cloud/spring-cloud-gateway
Add AsyncPredicate support to PredicateSpec.readBody()
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
I'm going to bring this up for discussion. Two simple changes to the ReadBodyPredicateFactory would make this filter way less limited than it currently is.
-
Cache the request body properly
The body of the request is currently cached in a ServerExchange attribute which is different from how the ModifyRequestBody caches it (decorated HttpMessage), making it impossible to use both at the same time.
The ModifyRequestBody approach is smarter because the filters downstream do not need to know about any custom attribute stored in the exchange, and the payload output class does not necessary need to be the same. -
Use the Mono version of the predicate
We should include a non-blocking version of the readBody method like
public <T> BooleanSpec readBody(Class<T> inClass, AsyncPredicate<T> predicate)
in addition to the existing method
public <T> BooleanSpec readBody(Class<T> inClass, Predicate<T> predicate)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating ReadBodyPredicateFactory and its existing PredicateSpec.readBody overload, then compare how ModifyRequestBody caches the decorated message. Check the surrounding gateway filter tests, if present, and consider the work complete when request-body caching can coexist with ModifyRequestBody and the non-blocking AsyncPredicate overload is supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100