Skip to content

Instantly share code, notes, and snippets.

@davejlong
Created November 28, 2016 02:04
Show Gist options
  • Save davejlong/d2d39d83558681a14777d710b38e4bc7 to your computer and use it in GitHub Desktop.
Save davejlong/d2d39d83558681a14777d710b38e4bc7 to your computer and use it in GitHub Desktop.
defmodule Uebersample.Router do
use Plug.Router
plug Ueberauth
alias Ueberauth.Strategy.Helpers
plug :match
plug :dispatch
get "/hello" do
conn |> send_resp(200, "Hello, World!")
end
get "/auth/:provider/callback" do
conn |> redirect("/hello")
end
match _ do
conn |> send_resp(404, "Oops! Page not found.")
end
defp redirect(conn, url) do
body = "<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>"
conn
|> put_resp_header("location", url)
|> put_resp_header("content-type", "text/html")
|> send_resp(conn.status || 302, body)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment