ha-handler/lib/ha_handler/web/router.ex

36 lines
809 B
Elixir
Raw Normal View History

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
2022-02-19 11:39:04 +01:00
# 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