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

Fix scope of used middleware in slice routes #1047

Closed
wants to merge 1 commit into from

Conversation

timriley
Copy link
Member

@jodosha Here's a failing spec demonstrating a couple of different problems with middleware being used inside slice routes.

I've started poking around but haven't yet found a fix. I'd imagine you might be a lot quicker with this given you recently built all of this – would you mind having a look?

Comment on lines +43 to +44
# With this here, it ends up applying to _all_ routes, including admin
use TestApp::Middleware, :main
Copy link
Member Author

Choose a reason for hiding this comment

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

One aspect of the problem: this shouldn't run on admin routes

Comment on lines +50 to +51
# With this here, all admin routes return 404
use TestApp::Middleware, :admin
Copy link
Member Author

Choose a reason for hiding this comment

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

And obviously this shouldn't make all the admin routes become 404s!

Copy link

Choose a reason for hiding this comment

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

I encountered this recently. admin routes become nested once more.

  • /admin/admin => admin's home#show
  • /admin/admin/test => admin's test#show

And main routes are nested in too, causing

  • /admin => main's home#show

I found it's because the Hanami::Application::Routing::Middleware::Stack creates a map for '/admin' but run the whole app under it.

@jodosha jodosha self-assigned this Feb 2, 2021
@jodosha jodosha self-requested a review February 2, 2021 10:41
@jodosha jodosha changed the base branch from unstable to main June 17, 2021 07:46
@solnic
Copy link
Member

solnic commented Jul 1, 2022

Closing this as it's outdated and I pushed a branch with the updated repro spec here https://github.com/hanami/hanami/tree/fix-slice-middlewares

@solnic solnic closed this Jul 1, 2022
@jodosha jodosha closed this Jul 1, 2022
@jodosha jodosha deleted the fix/scope-of-used-middleware-in-slice-routes branch July 1, 2022 07:58
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.

None yet

4 participants