39 lines
851 B
Elixir
39 lines
851 B
Elixir
defmodule HAHandler.Web.Router do
|
|
@moduledoc """
|
|
This module dispatch incoming HTTP requests to their
|
|
related logic. Please refer to [1] for details.
|
|
|
|
[1] https://hexdocs.pm/plug/Plug.Router.html#content
|
|
"""
|
|
|
|
use Plug.Router
|
|
|
|
alias HAHandler.Web.Controller
|
|
|
|
# Note for plugs: oder is important, as a plug may stop
|
|
# want to stop the pipeline!
|
|
|
|
plug(Plug.Logger, log: :debug)
|
|
|
|
# We use replug to allow for runtime configuration in release (as macros such
|
|
# as the `plug` call ae evaluated are compile-time).
|
|
plug(Replug,
|
|
plug: Plug.Static,
|
|
opts: {HAHandler, :acme_challenges_static_config}
|
|
)
|
|
|
|
plug(Replug,
|
|
plug: Plug.Static,
|
|
opts: {HAHandler, :assets_static_config}
|
|
)
|
|
|
|
plug(:match)
|
|
plug(:dispatch)
|
|
|
|
get("/", do: Controller.index(conn))
|
|
|
|
match _ do
|
|
send_resp(conn, 404, "Not found")
|
|
end
|
|
end
|