Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 20, 2016 21:10
Show Gist options
  • Save bnhansn/36ebe8d668189671c941660eba525a2b to your computer and use it in GitHub Desktop.
Save bnhansn/36ebe8d668189671c941660eba525a2b to your computer and use it in GitHub Desktop.
defmodule Sling.Router do
use Sling.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
plug Guardian.Plug.VerifyHeader, realm: "Bearer"
plug Guardian.Plug.LoadResource
end
scope "/", Sling do
pipe_through :browser
get "/", PageController, :index
end
scope "/api", Sling do
pipe_through :api
post "/sessions", SessionController, :create
delete "/sessions", SessionController, :delete
post "/sessions/refresh", SessionController, :refresh
resources "/users", UserController, only: [:create]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment