Skip to content

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

License

Notifications You must be signed in to change notification settings

soundtrackyourbrand/route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages