-
Notifications
You must be signed in to change notification settings - Fork 11
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
Deal with redirect codes #9
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.
Thanks @bigx333 Would you mind adding a test case for this?
@bigx333 I'll add the tests, thanks for the PR's! |
def check_redirect(conn) do | ||
conn | ||
|> Plug.Conn.register_before_send(fn conn -> | ||
case(conn.method in ["PUT", "PATCH", "DELETE"] and conn.status in [301, 302]) do |
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.
IMHO an if
statement would work better here :)
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.
thanks @zimt28 I just merged it so I could write the tests.
|> Plug.Conn.register_before_send(fn conn -> | ||
case(conn.method in ["PUT", "PATCH", "DELETE"] and conn.status in [301, 302]) do | ||
true -> | ||
conn |> put_status(303) |
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 could be better written without pipes, I think it's even suggested by Elixir (or at least Credo) to not do "single piping"
Implements https://inertiajs.com/redirects#303-response-code