Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 405 response bodies/headers cannot be customised #757

Open
atheriel opened this issue Feb 5, 2021 · 0 comments
Open

HTTP 405 response bodies/headers cannot be customised #757

atheriel opened this issue Feb 5, 2021 · 0 comments

Comments

@atheriel
Copy link
Contributor

atheriel commented Feb 5, 2021

Example application or steps to reproduce the problem

Every Plumber API sent an incorrect method to a valid route (e.g. PATCH /route where only GET /route is supported) is affected by this issue.

Describe the problem in detail

Plumber has pr_set_404() and pr_set_error() functions (among other, older approaches) that allow users to control the response body/headers of errors returned from an API. We use this extensively to emit common error structures. However, since #746 the HTTP 405 response has been hardcoded internally and it is no longer possible to control it.

This is not a bug per se (since it is intended behaviour) but it is a regression, since it was previously possible to control HTTP 405 responses from the 404 handler.

I originally proposed in #493 that Plumber have a dedicated handler for HTTP 405 responses (presumably pr_set_405()), and still believe that that is the right level of control here -- I would be happy to implement this myself, too.

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 a pull request may close this issue.

1 participant