throttler icon indicating copy to clipboard operation
throttler copied to clipboard

Pass more info for customization to throwThrottlingException()

Open iliazeus opened this issue 2 years ago • 1 comments

Is there an existing issue that is already proposing this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe it

It would be nice to have an ability to pass retry-after values and limits in the response body. Right now, the only ways to do that in the ThrottlerGuard subclasses are:

  • to parse the headers from the response object in throwThrottlingException()
  • to reimplement throttling logic in handleRequest()

Describe the solution you'd like

Pass an additional argument to throwThrottlingException() that would contain the nearestExpiryTime (and, ideally, the current request limit, and number of requests remaining).

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

An SMS/email code endpoint for authorization needs to allow no more than one request per IP+account per minute. The client app needs to show a countdown. Parsing headers in the client app is cumbersome.

iliazeus avatar Mar 30 '22 08:03 iliazeus

This seems rather straightforward. Would you like to create a PR for this?

jmcdo29 avatar Mar 30 '22 16:03 jmcdo29

Added to #1565 will be a part of the 5.0.0 release

jmcdo29 avatar Jul 06 '23 21:07 jmcdo29