View Source Voodoo (Bonfire v0.9.10-classic-beta.156)

Voodoo is a drop-in replacement for the old-style Phoenix path helpers (before Phoenix.VerifiedRoutes was introduced) which is more convenient to use.

Summary

Functions

Generates a reverse router function with the given name based upon a compiled(!) phoenix router module.

Turns a Conn or Socket into the name of the router that routed it.

Functions

Link to this macro

def_reverse_router(name, opts)

View Source (macro)

Generates a reverse router function with the given name based upon a compiled(!) phoenix router module.

Must be used outside of the router module, or else the router won't be compiled yet and we won't be able to look up the routes.

Generated function wraps the existing phoenix helpers.

defmodule MyAppWeb.Router do
  use MyAppWeb, :router
  # ...
end
defmodule MyAppWeb.Router.Reverse do
  import Voodoo, only: [def_reverse_router: 2]
  def_reverse_router :path, for: MyAppWeb.Router
end
@spec router(Conn.t() | Socket.t()) :: module()

Turns a Conn or Socket into the name of the router that routed it.