View Source Voodoo (bonfire_umbrella v0.9.6-classic-beta.12)

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.