multiplex v0.1.0 Multiplex

Phoenix router macro to dispatch multiple HTTP methods to a Plug

It provides a mux macro that generates a Phoenix route for each verb.

Edit web/web.ex and add the module:

def router do
  quote do
    use Phoenix.Router
    use Multiplex
  end
end

Then use the mux macro in your router to match one or more HTTP verbs with a Controller:

defmodule MyApp.Router do
  use HelloPhoenix.Web, :router

  mux [:get, :post], "/pages", PageController, :index
end

Summary

Macros

Main API to define multiple HTTP verbs for a route

Macros

mux(verbs, path, plug, plug_opts, options \\ [])

Specs

mux(term, [atom], String.t, atom, any, any) :: Macro.t

Main API to define multiple HTTP verbs for a route.

It accepts a list of HTTP methods as atoms, a path, a Plug, and its options.

Examples

 mux [:get, :post], "/pages/:page", PageController, :show