Skip to content

Instantly share code, notes, and snippets.

@fxn
Created September 9, 2015 21:33
Show Gist options
  • Save fxn/63cce27b8a55a3bc25d2 to your computer and use it in GitHub Desktop.
Save fxn/63cce27b8a55a3bc25d2 to your computer and use it in GitHub Desktop.
defmodule Hello.HelloController do
use Hello.Web, :controller
plug :action
def world(conn, %{"name" => name}) do
render conn, "world.html", name: name
end
end
defmodule Hello.HelloView do
use Hello.Web, :view
end
defmodule Hello.Router do
use Hello.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"]
end
scope "/", Hello do
pipe_through :browser # Use the default browser stack
get "/hello/:name", HelloController, :world
get "/", PageController, :index
end
# Other scopes may use custom stacks.
# scope "/api", Hello do
# pipe_through :api
# end
end
<h1>From layout: Hello <%= String.capitalize @name %>!</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment