spring-cloud / spring-cloud/spring-cloud-gateway

Create custom predicate based on body

Open
#3,957 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

I would like to redirect requests based on some information contained in the body for POST requests with XML content.

CacheRequestBodyFilter is executed after Predicates so ServerWebExchangeUtils.CACHED_REQUEST_BODY_ATTR is null at runtime. I have seen that before there was a ReadBodyPredicate but I guess it was replaced by CacheRequestBodyFilter.

The only alternative I could create a filter to do this and mutate the request to change the URI, but i don't like it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing predicate evaluation relative to CacheRequestBodyFilter and the ServerWebExchangeUtils.CACHED_REQUEST_BODY_ATTR mentioned in the issue. Review the prior ReadBodyPredicate reference and determine the supported design for routing POST requests from XML body content; done means the behavior is specified and covered for the relevant request flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.