Phoenix.Sync.Application (Phoenix.Sync v0.3.4)
View SourceSummary
Functions
Returns the required adapter configuration for your Phoenix Endpoint or
Plug.Router
.
Functions
@spec plug_opts() :: keyword()
Returns the required adapter configuration for your Phoenix Endpoint or
Plug.Router
.
Phoenix
Configure your endpoint with the configuration at runtime by passing the
phoenix_sync
configuration to your endpoint in the Application.start/2
callback:
def start(_type, _args) do
children = [
# ...
{MyAppWeb.Endpoint, phoenix_sync: Phoenix.Sync.plug_opts()}
]
end
Plug
Add the configuration to the Plug opts in your server configuration:
children = [
{Bandit, plug: {MyApp.Router, phoenix_sync: Phoenix.Sync.plug_opts()}}
]
Your Plug.Router
must be configured with
copy_opts_to_assign
and you should use
the rele
defmodule MyApp.Router do
use Plug.Router, copy_opts_to_assign: :options
use Phoenix.Sync.Controller
use Phoenix.Sync.Router
plug :match
plug :dispatch
sync "/shapes/todos", Todos.Todo
get "/shapes/user-todos" do
%{"user_id" => user_id} = conn.params
sync_render(conn, from(t in Todos.Todo, where: t.owner_id == ^user_id)
end
end