-
-
Notifications
You must be signed in to change notification settings - Fork 961
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
Feature: Expose Context.methodsAllowed for use by MethodNotAllowedHandler #870
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The default MethodNotAllowed handler uses
Context.methodsAllowed
to set the "Allow" header in the response.It would be nice to expose that list of allowed methods to a custom handler, as well.
Options I've considered:
Simply export that field of the
Context
struct. This would allow access when theContext
value is retrieved from ther.Context()
Add a function that extracts the unexported field from a context, and returns it. Something like:
Add a methodn on
Router
that takes a function that receives the list, and returns a handler. This seems really intrusive, though, and largely duplicates existing functionality:Re-calculate the list somehow. I don't see an efficient way to do this, but maybe I'm overlooking something.
As a last restort, I could potentially use a middeware that wraps the entire chi Mux, and detects the
Allow:
header to extract the values that way. MehThe text was updated successfully, but these errors were encountered: