moonzero · control plane v0.15.0 · 49 packages · 4 targets · Apache-2.0 docs / edge / route GitHub

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.

struct JwtRoute

structJWT 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 RouteOptions

structThe 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()) -> RouteOptions

fnOptions that change nothing: no prefix, no auth, no deadline, no cap.

fn RouteOptions::under( self : RouteOptions, prefix : String) -> RouteOptions

fnJoin 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) -> RouteOptions

fnRequire 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) -> RouteOptions

fnRequire a verified X-Content-Security signature on this route.

fn RouteOptions::timeout(self : RouteOptions, ms : Int64) -> RouteOptions

fnGive this route its own deadline in milliseconds.

fn RouteOptions::max_bytes( self : RouteOptions, bytes : Int32) -> RouteOptions

fnGive this route its own Content-Length cap in bytes.

fn RouteOptions::priority( self : RouteOptions, shedder : @shedder.Shedder) -> RouteOptions

fnDraw this route from the priority shedder, so a CPU spike sheds ordinary traffic before it touches these calls.

fn RouteOptions::sse(self : RouteOptions) -> RouteOptions

fnMark 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) -> String

fnJoin 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) -> String

fnjoin_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.