Skip to main content

Module site

Module site 

Source
Expand description

Sites — one tenant, several hostnames, each with its own root page.

The framework’s registry answers “which tenant owns this hostname” (rustango::tenancy::OrgHost). This answers the next question: once we are inside the tenant, which part of the page tree does that hostname serve?

§How a request finds its page

Without a site mapping the resolver anchors on the conventional empty-slug root, so anything else is reachable only under its own path — /site-b/about. Mapping a hostname to that page makes it answer at siteb.com/about instead.

The mapped page need not be a root. The prefix is only ever its url_path, so /campaigns/spring binds to a hostname exactly as a root does.

The translation is done at the edges rather than in the stored data:

  • on the way in, the request path is prefixed with the site root’s url_path before lookup;
  • on the way out, that prefix is stripped from generated links.

url_path therefore stays tenant-absolute and tree_ops is untouched. The alternative — storing site-relative paths — means moving a page between sites rewrites every descendant’s URL, and two roots would be free to collide on /about with nothing to tell them apart.

Structs§

Site
A hostname bound to a root page within this tenant.

Functions§

all
Every site mapping, newest hostname order, for the admin.
hosts_for_root
The hostnames rooted at root_page_id.
prefix_for_host
The URL prefix hostname serves under.
root_for_host
The page hostname is mapped to serve, or None when it serves the default root (no mapping, or one whose page has been deleted).
to_lookup_path
Prefix a public request path with the site root’s path.
to_public_path
Strip the site root’s prefix from a tenant-absolute url_path.