Skip to content

Pass through kwargs to middleware #267

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

Merged
merged 3 commits into from
Feb 17, 2024
Merged

Conversation

pat
Copy link
Contributor

@pat pat commented Nov 26, 2023

Most middleware expect the old-school approach of hash options, but some are now using keyword arguments instead (such as Rack::Timeout). So let's presume that any keyword arguments that aren't known by Hanami should be passed through.

There is the edge-case of both the middleware and Hanami expecting arguments with the same name - this does not address that. 😓

This PR is paired with a forthcoming one for hanami/hanami, as that's where the various parameters are captured.

@timriley timriley self-assigned this Feb 17, 2024
@timriley timriley added this to the v2.1.0 milestone Feb 17, 2024
@timriley
Copy link
Member

Thanks for this, @pat! This change looks good to me (revisiting this code, it kind of perplexes me that this class is inside router, but only invoked from inside hanami, but that shall be a topic for another day).

The one thing I noticed when inspecting this is that the updated test would still pass even if I disabled the updated implementation, so I've pushed a new test that requires a keyword arg to be properly passed through to the middleware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants