Skip to content

Instantly share code, notes, and snippets.

@skovsgaard
Created June 13, 2015 22:07
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 skovsgaard/92b1879ee6eb4f67eb61 to your computer and use it in GitHub Desktop.
Save skovsgaard/92b1879ee6eb4f67eb61 to your computer and use it in GitHub Desktop.
Plug setup
defmodule Elixir101 do
def prep, do: Elixir101.Builder.all
def start do
{:ok, _} = Plug.Adapters.Cowboy.http Elixir101.Server, []
end
end
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
@orendon
Copy link

orendon commented Jun 13, 2015

@skovsgaard think on at as a mask on the url, it will keep looking on priv/static

So, on this case the request should be http://localhost:4000/static/index.html and your file should be stored on priv/static/index.html

if you change to plug Plug.Static, at: "/", from: :elixir101 your request would be http://localhost:4000/index.html (file on same location)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment