Skip to content

Commit

Permalink
Add verified routes
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmay committed Oct 24, 2023
1 parent 325c316 commit 8617905
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/penguin_memories_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule PenguinMemoriesWeb do
below. Instead, define any helper function in modules
and import those modules here.
"""
def static_paths, do: ~w(assets fonts images favicon.ico robots.txt)

def controller do
quote do
Expand All @@ -24,6 +25,8 @@ defmodule PenguinMemoriesWeb do
import Plug.Conn
import PenguinMemoriesWeb.Gettext
alias PenguinMemoriesWeb.Router.Helpers, as: Routes

unquote(verified_routes())
end
end

Expand Down Expand Up @@ -93,6 +96,17 @@ defmodule PenguinMemoriesWeb do
import PenguinMemoriesWeb.Gettext
import PenguinMemoriesWeb.ViewHelpers
alias PenguinMemoriesWeb.Router.Helpers, as: Routes

unquote(verified_routes())
end
end

def verified_routes do
quote do
use Phoenix.VerifiedRoutes,
endpoint: PenguinMemoriesWeb.Endpoint,
router: PenguinMemoriesWeb.Router,
statics: PenguinMemoriesWeb.static_paths()
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/penguin_memories_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule PenguinMemoriesWeb.Endpoint do
at: "/",
from: :penguin_memories,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
only: PenguinMemoriesWeb.static_paths()

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
Expand Down
2 changes: 2 additions & 0 deletions test/support/conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ defmodule PenguinMemoriesWeb.ConnCase do

# The default endpoint for testing
@endpoint PenguinMemoriesWeb.Endpoint

use AppWeb, :verified_routes
end
end

Expand Down

0 comments on commit 8617905

Please sign in to comment.