1

I got a simple Plug post handler like this

post "/some/url" do
   # do something
   # render(something)
end

…but I would like to redirect somehow to another get handler, instead of rendering html.

How to do this using plug_cowboy 2.0?

gunnar2k
  • 185
  • 1
  • 13

1 Answers1

5

There is no magic: you have to send HTTP 302 response:

conn
|> put_resp_header("location", url)
|> send_resp(conn.status || 302, "text/html", body)

Phoenix does the same.

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160