diff --git a/lib/media_server_web.ex b/lib/media_server_web.ex index af3fdc84..a03fa0fd 100644 --- a/lib/media_server_web.ex +++ b/lib/media_server_web.ex @@ -17,13 +17,18 @@ defmodule MediaServerWeb do and import those modules here. """ + def static_paths, do: ~w(assets fonts images manifest browserconfig favicon logo android-icon apple-icon ms-icon) + def controller do quote do use Phoenix.Controller, namespace: MediaServerWeb import Plug.Conn import MediaServerWeb.Gettext + alias MediaServerWeb.Router.Helpers, as: Routes + + unquote(verified_routes()) end end @@ -89,7 +94,19 @@ defmodule MediaServerWeb do import MediaServerWeb.ErrorHelpers import MediaServerWeb.Gettext + alias MediaServerWeb.Router.Helpers, as: Routes + + unquote(verified_routes()) + end + end + + def verified_routes do + quote do + use Phoenix.VerifiedRoutes, + endpoint: MediaServerWeb.Endpoint, + router: MediaServerWeb.Router, + statics: MediaServerWeb.static_paths() end end diff --git a/lib/media_server_web/endpoint.ex b/lib/media_server_web/endpoint.ex index 13bec0c9..9f5f10ac 100644 --- a/lib/media_server_web/endpoint.ex +++ b/lib/media_server_web/endpoint.ex @@ -22,8 +22,7 @@ defmodule MediaServerWeb.Endpoint do at: "/", from: :media_server, gzip: false, - only_matching: - ~w(assets fonts images manifest browserconfig favicon logo android-icon apple-icon ms-icon) + only_matching: MediaServerWeb.static_paths() # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index b60e6a01..9055e03c 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -19,6 +19,8 @@ defmodule MediaServerWeb.ConnCase do using do quote do + use MediaServerWeb, :verified_routes + # Import conveniences for testing with connections import Plug.Conn import Phoenix.ConnTest