Can anyone provide full example of Router + Controller + Ecto usage? I’m interested to find out how to propagate the tenant name down to the service layer. My current thinking is
router.ex
pipeline :tenant do
plug Triplex.SubdomainPlug,
endpoint: CcbApiWeb.Endpoint
plug Triplex.EnsurePlug,
failure_callback: &CcbApiWeb.Tenant.Helper.ensure_loaded_failure/2
end
scope "/api", CcbApiWeb do
pipe_through :api
...
scope "/" do
pipe_through :tenant
resources "/customers", CustomerController, except: [:new, :edit]
...
customer_controller.ex
...
def index(conn, _params) do
customers = Customers.list_customers(conn.assigns)
render(conn, "index.json", customers: customers)
end
...
customers.ex
def list_customers(assigns) do
Repo.all(Customer, prefix: Triplex.to_prefix(assigns))
end
Are there any macros that can help me out here?






















