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

05 / EDGE

hoops

One hoop per option that can refuse a request, applied where the route is registered: the token, the signature, the declared body length, the deadline enforced by racing the handler, the shedder's ticket, and the event-stream headers.

fn jwt_accepts( setting : JwtRoute, token : String?, now_secs : Int64) -> Bool

fnWhether token verifies against the route's current secret, or against the one a rotation is retiring, at now_secs.

fn jwt_hoop(setting : JwtRoute, clock : @clock.Clock) -> @route.Hoop

fnThe JWT hoop: refuse the route unless the bearer token verifies.

fn timeout_hoop(budget_ms : Int64) -> @route.Hoop

fnThe timeout hoop: run the rest of the chain under a budget, and answer 503 when it runs out. The deadline is enforced here rather than on the response path, so a handler that never returns is abandoned instead of hanging the request forever.

fn max_bytes_hoop(limit : Int32) -> @route.Hoop

fnThe max-bytes hoop: refuse a body whose declared length exceeds limit.

fn signature_hoop( verifier : @handler.SignatureVerifier, clock : @clock.Clock) -> @route.Hoop

fnThe signature hoop: verify the X-Content-Security MAC and timestamp on this route. A payload the envelope declares encrypted is *not* decrypted here — a hoop cannot rewrite the request — so a route that takes encrypted bodies wants the service-level content_security layer, which can.

fn sse_hoop() -> @route.Hoop

fnThe SSE hoop: stamp the event-stream media type, no caching and a kept-alive connection onto a buffered response. A streamed reply declares its own headers and is left alone.

fn priority_hoop(shedder : @shedder.Shedder) -> @route.Hoop

fnThe priority hoop: draw this route from shedder. A refused call answers 503, the status shedding interceptor uses.

fn hoops_of(options : RouteOptions) -> Array[@route.Hoop]

fnThe hoops options asks for, outermost first: signature, JWT, body cap, deadline, priority shedding, then the SSE stamp. Checks that refuse come before the ones that only measure, so a refused request costs nothing.