Expand description
Sites served under a path on the main domain (example.com/acme/)
rather than on a host of their own.
The framework sends a path-prefix tenant’s requests to the host app
with the prefix still on the path (/acme/about), but every CMS route,
page path and link is written from the site’s root. serve wraps the
host’s router so a site works the same under a prefix:
- on the way in, the prefix comes off the path (
/acme/aboutis served as/about). The framework finds the tenant again in every handler from the request, which no longer shows the prefix, so the site is named in a header the host’s resolver reads (tenant_header); a copy sent by the client is always dropped first; - on the way out, it goes back on: redirects, cookie paths, and the
root-relative addresses in HTML, CSS, JavaScript and JSON (links,
pictures, forms, and the admin’s own
/cms-admin/…calls). Absolute addresses (sitemap, feeds, robots.txt) carry it throughPREFIX_HEADER.
A host wires both halves:
ⓘ
rustango::manage::Cli::new()
.tenancy()
.tenant_header(rustango_cms::path_prefix::tenant_header())
.api(rustango_cms::path_prefix::serve(api))Sites on their own host pass through untouched.
Constants§
- PREFIX_
HEADER - The prefix taken off the request (
/acme). Set only byserve; absolute addresses add it after the host. - TENANT_
HEADER - Names the site a stripped request belongs to, for the framework’s
resolver. Set only by
serve.
Functions§
- of
- The prefix
servetook off this request, if any. - serve
router, serving path-prefix sites from their prefix.- site_
path pathas the site sees it: without the prefixservetook off this request. For addresses the browser reports (location.pathname).- tenant_
header - The resolver that finds a stripped request’s site, for
Cli::tenant_header.