-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Add redirect_back functionality #1168
Add redirect_back functionality #1168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look great. The only thing I'm wondering is redirect
allows for a HTTP::Status
to be passed... I'm wondering if we should also include a method overload for that....
@jwoertink Good catch, there are just sooo many overloads! |
73f90c1
to
231d58d
Compare
😂 yup, but this is awesome! I saw what you mean with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One tiny comment then LGTM! Thanks for tackling this!
Looks great! Thank you 🎉 |
Purpose
Fixes #1158
redirect_back
allows an action to send the user back to where they made the request from. This is really useful in situations like submitting a lead form where the app might have it in several locations but the app doesn't need to take them anywhere in particular after they submit it. Rather than sending the user to a specific place after submitting the form, we can now send them back to where they originally submitted it.This was largely taken from Rails. source
Sidenote
If you look at the Rails code, there is functionality around limiting Referer redirects in some situations using the
allow_other_hosts
named argument. If it is set tofalse
then it will not redirect to a Referer header that has a different host than the request host. So, if the app is running atexample.com
, it will not redirect to a Referer header ofdifferenturl.com
when set to false. While this might be useful, I didn't want to copy it over just to copy it.Description
Usage looks like:
It's important that the fallback is required because the
Referer
header is not guaranteed so we need to send the user somewhere.Checklist
crystal tool format spec src
./script/setup
./script/test