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

Deal with redirect codes #9

Merged
merged 1 commit into from
Feb 17, 2020
Merged

Deal with redirect codes #9

merged 1 commit into from
Feb 17, 2020

Conversation

bigx333
Copy link
Contributor

@bigx333 bigx333 commented Feb 17, 2020

Copy link
Collaborator

@tmartin8080 tmartin8080 left a 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?

@tmartin8080
Copy link
Collaborator

@bigx333 I'll add the tests, thanks for the PR's!

@tmartin8080 tmartin8080 merged commit 3a8a3b4 into devato:develop Feb 17, 2020
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
Copy link
Contributor

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 :)

Copy link
Collaborator

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)
Copy link
Contributor

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants