defmodule ApiPlayground do @moduledoc """ Documentation for ApiPlayground. """ def init(opts), do: opts def call(conn, opts) do router = Keyword.get(opts, :router) routes = router.__routes__ conn |> Plug.Conn.assign(:routes, routes) |> ApiPlayground.Router.call(opts) end end defmodule ApiPlayground.Router do use Plug.Router plug Plug.Static, at: "/", from: "priv/static" plug :match plug :dispatch get "/" do send_resp(conn, 200, ApiPlayground.View.render(conn.assigns)) end end defmodule ApiPlayground.View do require EEx EEx.function_from_file :def, :render, "lib/templates/index.html.eex", [:assigns] end