Multitenancy.SiteResolver behaviour (multitenancy_phoenix v0.2.0)

Copy Markdown View Source

Resolves a request host into a Multitenancy.Site.

Implement this behaviour to load sites from any source (database, external API, ...) and configure it with:

config :multitenancy_phoenix, resolver: MyApp.SiteResolver

Summary

Callbacks

Resolves a site from the whole request, for lookups that need more than the host (a header, a path prefix, ...). When implemented, Multitenancy.Plug.ResolveSite calls it instead of resolve/1.

Callbacks

resolve(host)

@callback resolve(host :: String.t()) :: {:ok, Multitenancy.Site.t()} | :error

resolve_conn(t)

(optional)
@callback resolve_conn(Plug.Conn.t()) :: {:ok, Multitenancy.Site.t()} | :error

Resolves a site from the whole request, for lookups that need more than the host (a header, a path prefix, ...). When implemented, Multitenancy.Plug.ResolveSite calls it instead of resolve/1.