~afontaine/home

e089abae5bc1bf9268e30b0256ed288ae1dbadf0 — Andrew Fontaine 8 months ago 8dd5ea8
Add Well Known Controller for .well-known Requests

Right now the only expected one is for stellar.
A apps/home_web/lib/home_web/controllers/well_known_controller.ex => apps/home_web/lib/home_web/controllers/well_known_controller.ex +14 -0
@@ 0,0 1,14 @@
defmodule HomeWeb.WellKnownController do
  use HomeWeb, :controller

  def index(conn, %{"path" => "stellar.toml"}) do
    text(conn, "FEDERATION_SERVER=\"https://stellarid.io/federation/\"")
  end

  def index(conn, _),
    do:
      conn
      |> put_status(:not_found)
      |> put_view(HomeWeb.ErrorView)
      |> render(:"404")
end

M apps/home_web/lib/home_web/router.ex => apps/home_web/lib/home_web/router.ex +6 -0
@@ 14,6 14,12 @@ defmodule HomeWeb.Router do
  end

  scope "/", HomeWeb do
    pipe_through :api

    get "/.well-known/:path", WellKnownController, :index
  end

  scope "/", HomeWeb do
    pipe_through :browser

    get "/", PageController, :index