35 lines
806 B
Elixir
35 lines
806 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
|
|
|
|
import HAHandler, only: [acme_challenge_path: 0]
|
|
|
|
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
|
|
# Note: `plug` is a macro, hence evaluated at
|
|
# compile-time. The configuration (which path to
|
|
# serve) cannot be modified at runtime with this
|
|
# system.
|
|
plug Plug.Static,
|
|
at: "/.well-known/acme-challenge/",
|
|
from: acme_challenge_path()
|
|
|
|
plug :match
|
|
plug :dispatch
|
|
|
|
get "/", do: Controller.index(conn)
|
|
|
|
match _ do
|
|
send_resp(conn, 404, "Not found")
|
|
end
|
|
end
|