Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 1.04 KB

README.md

File metadata and controls

56 lines (40 loc) · 1.04 KB

Route

Build Status Inline docs

Elixir macro for routing to multiple routers from phoenix endpoint (or a plug router)

Documentation for route is available online.

Example

defmodule Endpoint do
  use Phoenix.Endpoint, otp_app: :my_app
  use Route

  route path: "/admin", to: Admin.Router
  route host: "api.", to: API.Router
  route to: Web.Router
end

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

  get "/" do
    resp(conn, 200, "hello api")
  end
end

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

  get "/" do
    resp(conn, 200, "hello web")
  end
end

defmodule Web.Admin do
  use MyApp.Web, :router

  get "/" do
    resp(conn, 200, "hello admin")
  end
end

Installation

Add route to your mix.exs dependencies:

def deps do
  [{:route, "~> 1.0"}]
end