04 / EDGE
route
The settings a route carries into its own registration: a JWT with a rotation window, a signature verifier, a deadline, a body cap, the priority shedder, a prefix and server-sent events. Each is a field of RouteOptions and a hoop on the route.
WHERE IT SITS
INTERFACE
struct JwtRoutestructJWT settings attached to a route: the current secret and, during a rotation, the previous one.
let no_jwt : JwtRoute =letJWT settings that authenticate nothing.
struct RouteOptionsstructThe per-route settings. Every one of them defaults to "inherit": no timeout, no body cap, no JWT, no signature, ordinary priority, no SSE.
fn RouteOptions::new( clock~ : @clock.Clock = @clock.Clock::system()) -> RouteOptionsfnOptions that change nothing: no prefix, no auth, no deadline, no cap.
fn RouteOptions::under( self : RouteOptions, prefix : String) -> RouteOptionsfnJoin group onto this option set's prefix, so a sub-group inherits the parent prefix as well as its own.
fn RouteOptions::jwt( self : RouteOptions, secret~ : String, prev_secret? : String) -> RouteOptionsfnRequire a valid Authorization: Bearer <jwt> on this route. prev_secret is the secret a rotation is retiring: a token signed with it is still accepted until the rotation window closes, which is what lets clients refresh without a coordinated deploy.
fn RouteOptions::signature( self : RouteOptions, verifier : @handler.SignatureVerifier) -> RouteOptionsfnRequire a verified X-Content-Security signature on this route.
fn RouteOptions::timeout(self : RouteOptions, ms : Int64) -> RouteOptionsfnGive this route its own deadline in milliseconds.
fn RouteOptions::max_bytes( self : RouteOptions, bytes : Int32) -> RouteOptionsfnGive this route its own Content-Length cap in bytes.
fn RouteOptions::priority( self : RouteOptions, shedder : @shedder.Shedder) -> RouteOptionsfnDraw this route from the priority shedder, so a CPU spike sheds ordinary traffic before it touches these calls.
fn RouteOptions::sse(self : RouteOptions) -> RouteOptionsfnMark this route as a server-sent-event stream: the response carries the SSE media type, no caching, and a keep-alive connection.
fn join_path(prefix : String, path : String) -> StringfnJoin a prefix with a path into a single, normalised path: at most one slash between the two, a guaranteed leading slash, and "/" for the empty result.
fn join_prefix(prefix : String, path : String) -> Stringfnjoin_path for a prefix that may be absent: two empty prefixes stay empty rather than collapsing to the root path, so a group with no prefix of its own adds nothing to a route.