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

Introduce mounting cascade apps #1471

Merged
merged 3 commits into from Oct 25, 2013
Merged

Introduce mounting cascade apps #1471

merged 3 commits into from Oct 25, 2013

Conversation

ujifgc
Copy link
Member

@ujifgc ujifgc commented Oct 23, 2013

More info at #796

Router will traverse through apps in mount order.
If app mount path matches the request and the app returns 404, router will call next app with matching mount path.
If no apps with matching path return non-404 response, router will return the 404 of the last app.

Update: configure cascade codes: #1471 (comment)

@namusyaka
Copy link
Contributor

Perhaps, rack-protection is the cause of problem.
if change padrino-core.gemspec (>= 1.5.0 to = 1.5.0), it works.

@ujifgc
Copy link
Member Author

ujifgc commented Oct 23, 2013

Thanks for the tip! I updated the bundle on my machine and got this failure.

So, rack-protection >= 1.5.1 breaks this feature: f1e989f #1391

The last successful Travis build was with rack-protection 1.5.0 https://travis-ci.org/padrino/padrino-framework/jobs/12674078#L274

@namusyaka
Copy link
Contributor

Looks great!

@Ortuna
Copy link
Member

Ortuna commented Oct 24, 2013

Would this cascade to the next app if the first explicitly returns 404? That may not be desired(maybe an edge case). e.g. route is matched in app #1 but 404 is returned.

@ujifgc
Copy link
Member Author

ujifgc commented Oct 24, 2013

Well, that's how cascading is defined in Rack http://rack.rubyforge.org/doc/classes/Rack/Cascade.html

@Ortuna
Copy link
Member

Ortuna commented Oct 24, 2013

got it, just wondering.

@ujifgc
Copy link
Member Author

ujifgc commented Oct 24, 2013

I guess, it won't hurt to add configurable status code. On it.

@ujifgc
Copy link
Member Author

ujifgc commented Oct 24, 2013

You can configure HTTP codes for cascade apps like this:

config/apps.rb:

Padrino.mount("API").to('/foo')
Padrino.mount("Blocker", :cascade => [403]).to('/foo')
Padrino.mount("Application", :cascade => false).to('/foo')
Padrino.mount("LastResort").to('/foo')

In this case the request will pass API on it's 404 and 405 (default pass codes), will pass Blocker on it's 403, won't get to LastResort, it will end on Application.

@dariocravero
Copy link

This looks very good @ujifgc 👍! :)

@Ortuna
Copy link
Member

Ortuna commented Oct 24, 2013

👍

ujifgc added a commit that referenced this pull request Oct 25, 2013
Introduce mounting cascade apps
@ujifgc ujifgc merged commit eab583a into master Oct 25, 2013
@ujifgc ujifgc deleted the cascade-apps branch October 25, 2013 06:04
@nesquena
Copy link
Member

Awesome, nice work @ujifgc. Padrino 0.12.0 is coming along fast with all your guys great contributions. Only 22 open issues. Great work @padrino/core-members!

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

5 participants