Skip to main content

Crate holger_front

Crate holger_front 

Source
Expand description

holger.rs’s front page — the whole public door, as one pure function.

holger-server is a hand-rolled hyper dispatcher with no router, no template engine and no static-asset tree; until now GET / answered 404 Unknown repository. So this crate is not a framework and does not try to be one: it is route, a function from a method and a path to a Reply, and mounting it in server/lib/src/exposed/http.rs is four lines next to the /-/search arm.

That shape is the point. Everything the page is — the bytes, the JSON, the cache headers, the refusals — is decided here, where it can be tested in a crate that builds in seconds, rather than inside a request handler that needs the whole server to compile.

§The two doors

pathwhat it answers
GET /the page (one self-contained HTML file)
GET /holger.webpthe picture on its left half
GET /-/frontwho this server is, and whether it has a browser login
GET /-/releasesthe catalogue: the public repositories, and the latest version of each package

§★ The one rule about version numbers

This crate never decides which version is newest. latest_by groups and folds, but the comparison is a function the caller passes in, and the caller is server/lib, which passes retention::cmp_version — the comparator holger already uses to decide which artifact a retention sweep must not delete.

That is not indirection for its own sake. A front page that ranked versions with its own comparator would be a SECOND source of truth for “the latest release”, and the first time somebody published 1.10.0 beside 1.9.0 the page and holger retention would name different artifacts as the newest — with no way to tell which of them was wrong.

Structs§

Catalogue
What /-/releases answers: the roster and the rows, in one document.
Doors
What the server must hand the door to answer it.
Front
What /-/front answers: everything on the page that is a fact about THIS server rather than about holger.
Login
The door a browser can actually walk through, if there is one.
Release
One row of the front page’s table, and there is no fourth field.
Reply
One answer: a status, a content type, headers that matter, and the bytes.
Repository
One public repository, as a stranger may see it.

Enums§

Door
WHICH OF THE THREE STATES the door is in — the third one is new.

Constants§

CONSOLE_LABEL
What the button says when the door is the console.
FRONT_PATH
IGNALINA_MARK
IGNALINA_PATH
Where the Ignalina mark is served — a square avatar, 18x18.
PAGE
The page, as served. One file: holger-server has nowhere to serve a second one from.
PASSKEY_LABEL
What the button says when the ceremony is on this page, and it is the estate’s word.
PICTURE
The picture on the left half.
PICTURE_PATH
Where the picture is served, named once here and once in the page’s --backdrop-image. A test asserts they agree.
RELEASES_PATH
VETRA_MARK
The makers’ marks, compiled in for the same reason the picture is — and served from THIS origin rather than hotlinked. An avatar fetched off a third party’s CDN would need a hole in this page’s policy and would hand every visitor’s address to that third party for two files under 4 kB. Copied from gunnar-ui, so the estate’s two fronts credit their makers identically.
VETRA_PATH
Where the Vetra wordmark is served. A WORDMARK, so the page sizes it by height only (96x18 from its own 1380x260 viewBox); forcing it square would squash five letters.

Functions§

artifact_name
How a namespaced coordinate becomes the single string in the middle column.
console_login
The console door, or None — and None is the answer for anything the PAGE would refuse to follow.
latest_by
Fold every (repository, artifact, version) down to the newest version of each (repository, artifact), using newer to compare.
page_refusals
The three sentences the PAGE prints on its own.
passkey_login_here
The third state: the passkey ceremony, on this page.
reads_gated
The refusal for a server whose reads are gated, so /-/front cannot be read at all. Produced by the CALLER, which is the half that knows about require_auth_for_reads; it lives here so the code and the words are in the same place as the page that prints them.
route
The whole public surface, as a pure function.