Created
September 9, 2015 21:33
-
-
Save fxn/63cce27b8a55a3bc25d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Hello.HelloController do | |
use Hello.Web, :controller | |
plug :action | |
def world(conn, %{"name" => name}) do | |
render conn, "world.html", name: name | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Hello.HelloView do | |
use Hello.Web, :view | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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