Redirect to production: a visitor's request for a public URL goes to the same path on the configured production site.
Smart on purpose — this site is where the agency works, so nobody who is
meant to be here is sent away: a logged-in user is not redirected, a path
under the admin prefix is not (the admin came here to do admin work), the
gate page and assets are not. Scope narrows it further: "everyone", or
"crawlers" — only search-engine crawlers, by user agent — so a staging
site can keep its humans and lose its index.
A 302, never a 301: browsers cache a 301, and this is temporary by nature.
Summary
Functions
Whether user_agent looks like a search-engine crawler.
Where conn should be sent, or nil when it stays. logged_in? is decided
by the caller (the plug already resolves the session user for maintenance).
The production URL parsed and checked: http(s), a host, no userinfo, no query, no fragment, no whitespace or control characters; the path (if any) is kept as a prefix without its trailing slash. Nil otherwise.
The production URL, normalised without a trailing slash; nil when unset or not http(s).
Functions
Whether user_agent looks like a search-engine crawler.
@spec enabled?() :: boolean()
@spec scope() :: String.t()
@spec switched_on?() :: boolean()
@spec target_for(Plug.Conn.t(), keyword()) :: String.t() | nil
Where conn should be sent, or nil when it stays. logged_in? is decided
by the caller (the plug already resolves the session user for maintenance).
@spec target_uri() :: URI.t() | nil
The production URL parsed and checked: http(s), a host, no userinfo, no query, no fragment, no whitespace or control characters; the path (if any) is kept as a prefix without its trailing slash. Nil otherwise.
@spec target_url() :: String.t() | nil
The production URL, normalised without a trailing slash; nil when unset or not http(s).