Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Last active August 23, 2017 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankardevy/efaff9abfd49e4e5b7b431f28dda6035 to your computer and use it in GitHub Desktop.
Save shankardevy/efaff9abfd49e4e5b7b431f28dda6035 to your computer and use it in GitHub Desktop.
defmodule MangoWeb.Router do
use MangoWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :frontend do
plug MangoWeb.Plugs.LoadCustomer
plug MangoWeb.Plugs.FetchCart
plug MangoWeb.Plugs.Locale
end
pipeline :admin do
plug MangoWeb.Plugs.AdminLayout
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", MangoWeb do
pipe_through [:browser, :frontend]
# Add all routes that don't require authentication
get "/login", SessionController, :new
post "/login", SessionController, :create
get "/register", RegistrationController, :new
post "/register", RegistrationController, :create
get "/", PageController, :index
get "/categories/:name", CategoryController, :show
get "/cart", CartController, :show
post "/cart", CartController, :add
put "/cart", CartController, :update
end
scope "/", MangoWeb do
pipe_through [:browser, :frontend, MangoWeb.Plugs.AuthenticateCustomer]
# Add all routes that require authentication
get "/logout", SessionController, :delete
get "/checkout", CheckoutController, :edit
put "/checkout/confirm", CheckoutController, :update
resources "/tickets", TicketController, except: [:edit, :update, :delete]
end
scope "/admin", MangoWeb.Admin, as: :admin do
pipe_through [:browser, :admin]
resources "/users", UserController
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment