Created
June 13, 2015 22:07
-
-
Save skovsgaard/92b1879ee6eb4f67eb61 to your computer and use it in GitHub Desktop.
Plug setup
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 Elixir101 do | |
def prep, do: Elixir101.Builder.all | |
def start do | |
{:ok, _} = Plug.Adapters.Cowboy.http Elixir101.Server, [] | |
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 Elixir101.Server do | |
use Plug.Builder | |
plug Plug.Static, at: "/static", from: :elixir101 | |
plug :not_found | |
def not_found(conn, _) do | |
send_resp conn, 404, "not found" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@skovsgaard think on
at
as a mask on the url, it will keep looking on priv/staticSo, on this case the request should be
http://localhost:4000/static/index.html
and your file should be stored onpriv/static/index.html
if you change to
plug Plug.Static, at: "/", from: :elixir101
your request would behttp://localhost:4000/index.html
(file on same location)