Liking cljdoc? Tell your friends :D

dev.arkaitz.web-base.gate

The gate on private pages (SPEC §5, §9). The base knows that a request may carry a subject and nothing about what a subject is: the host hands it a function from request to subject-or-nil, and per route a predicate over the request. What the base owns is the translation of a refusal into the right outcome for the kind of request — a 303 for a navigation, so a refused POST is never re-posted to the login page; an HX-Redirect for an htmx swap so the login page never lands inside a div; and a 403 error datum when there is a subject and the predicate still says no. No 401: a proper one needs WWW-Authenticate, and only whoever authenticates knows the scheme.

The gate on private pages (SPEC §5, §9). The base knows that a request may
carry a subject and nothing about what a subject is: the host hands it a
function from request to subject-or-nil, and per route a predicate over the
request. What the base owns is the translation of a refusal into the right
outcome for the kind of request — a `303` for a navigation, so a refused
POST is never re-posted to the login page; an `HX-Redirect` for an htmx swap
so the login page never lands inside a `div`; and a 403 error datum when
there is a subject and the predicate still says no. No `401`: a proper one
needs `WWW-Authenticate`, and only whoever authenticates knows the scheme.
raw docstring

middlewareclj

(middleware {:keys [login-path] :as opts})

reitit middleware compiled per route: it vanishes from routes without :wb/gate (absent or nil), and fails at router construction when the gate is present but not callable — false would otherwise open a route without a symptom — or when no :login-path is configured, which would otherwise be a 500 on the first refused request. reitit hands the compile step the route data, not the path, so the errors name the config key.

reitit middleware compiled per route: it vanishes from routes without
`:wb/gate` (absent or nil), and fails at router construction when the gate
is present but not callable — `false` would otherwise open a route without
a symptom — or when no `:login-path` is configured, which would otherwise
be a 500 on the first refused request. reitit hands the compile step the
route data, not the path, so the errors name the config key.
sourceraw docstring

subject-present?clj

(subject-present? request)

The stock predicate: there is a subject. Presence is all the base ever checks; it never looks inside, so false is a subject like any other.

The stock predicate: there is a subject. Presence is all the base ever
checks; it never looks inside, so `false` is a subject like any other.
sourceraw docstring

wrap-subjectclj

(wrap-subject handler subject-fn)

Puts (subject-fn request) on every request as :wb/subject, gated route or not — a public page's layout also paints the identity corner.

Puts `(subject-fn request)` on every request as `:wb/subject`, gated route
or not — a public page's layout also paints the identity corner.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close