Skip to content

Ability to specify response HTTP status code for Throttle middleware#571

Merged
VojtechVitek merged 2 commits into
go-chi:masterfrom
vasayxtx:throttle-middleware-custom-status-code
Sep 18, 2024
Merged

Ability to specify response HTTP status code for Throttle middleware#571
VojtechVitek merged 2 commits into
go-chi:masterfrom
vasayxtx:throttle-middleware-custom-status-code

Conversation

@vasayxtx

Copy link
Copy Markdown
Contributor

Some time ago the PR #528 was merged but seems like in some cases 503 HTTP code is more suitable. Actually, using 503 or 429 response code for rate/conn limiting is a controversial topic. As for me, 429 HTTP code should be used when a specific client is breaking a contract by making too many requests over a certain period of time. It will be a bit strange if the client receives 429 on its first request.

P.S.:

This PR provides the ability to specify the needed status code. Could you please consider it?

@pkieltyka

Copy link
Copy Markdown
Member

thanks for the PR. I'll need to find some head space to think about this

@senekis

senekis commented Sep 30, 2022

Copy link
Copy Markdown

Any news on this PR?

Agree with @vasayxtx, allowing to custom the status code (eg. 503) is better than always returning 429. It is misleading for the clients of the service, if they receive a 429 error will think are reaching their limits and that modifying the pace will make the error go away, but no, they will continue getting the errors, so is more suitable in this case 503.

@vasayxtx vasayxtx force-pushed the throttle-middleware-custom-status-code branch from 3430082 to a62d96e Compare December 27, 2023 20:25
@vasayxtx

vasayxtx commented Dec 27, 2023

Copy link
Copy Markdown
Contributor Author

I've just resolved the conflict, so the PR is ready for review/merge:)
@pkieltyka JFYI

@vasayxtx vasayxtx force-pushed the throttle-middleware-custom-status-code branch 2 times, most recently from 6b3da1b to bccb994 Compare December 28, 2023 09:00
@vasayxtx vasayxtx force-pushed the throttle-middleware-custom-status-code branch from bccb994 to c9c6c17 Compare December 28, 2023 11:19

@VojtechVitek VojtechVitek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants