View Source Voodoo (bonfire v0.3.5-classic-beta.7)

Link to this section 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.

Link to this section 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.