Coherence.Router (Coherence v0.8.0)

Handles routing for Coherence.

Usage

Add the following to your web/router.ex file

defmodule MyProject.Router do
  use MyProject.Web, :router
  use Coherence.Router         # Add this

  pipeline :browser do
    plug :accepts, ["html"]
    # ...
    plug Coherence.Authentication.Session           # Add this
  end

  pipeline :protected do
    plug :accepts, ["html"]
    # ...
    plug Coherence.Authentication.Session, protected: true
  end

  scope "/" do
    pipe_through :browser
    coherence_routes()
  end

  scope "/" do
    pipe_through :protected
    coherence_routes :protected
  end
  # ...
end

Alternatively, you may want to use the login plug in individual controllers. In this case, you can have one pipeline, one scope and call coherence_routes :all. In this case, it will add both the public and protected routes.

Summary

Functions

Link to this macro

coherence_routes(mode \\ [], opts \\ [])

(macro)

Coherence Router macro.

Use this macro to define the various Coherence Routes.

Examples:

# Routes that don't require authentication
scope "/" do
  pipe_through :browser
  coherence_routes
end

# Routes that require authentication
scope "/" do
  pipe_through :protected
  coherence_routes :protected
end