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

Rate Limit Response - I'd like to modify the body

Open
#1,810 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

https://github.com/spring-cloud/spring-cloud-gateway/blob/223165882707f2b9242e27c2d3851a9d76b04b6f/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/RequestRateLimiterGatewayFilterFactory.java#L129

I'd like to customise the body when Rate Limit filter returns 429.

I can add the headers I want, but body is empty and I have a requirement to customise it.
I've tried other filter combinations, they work ok for other responses but it seems after this response is set to complete none of the filter / modifications are applied

Is there any workaround I could apply? Or any chance custom body is added any time soon to
org.springframework.cloud.gateway.filter.ratelimit.RateLimiter.Response ?

Thanks!

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 at spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/RequestRateLimiterGatewayFilterFactory.java around line 129, then inspect org.springframework.cloud.gateway.filter.ratelimit.RateLimiter.Response. Determine how a caller could provide a body for the 429 response and validate that the configured body is returned instead of an empty response.

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
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.