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

07 / CONTROL

refusal

What a request refused by a middleware receives: 503 for an open breaker, a spent connection budget or a passed deadline, 429 for a rate limit, 413 for a body too large. Each is a parameter.

struct Refusal

structThe response a refused request receives: a status, a body, and the headers sent with it.

let plain_text : Array[(String, String)] = [

letThe headers a refusal carries unless told otherwise.

fn Refusal::new( status~ : Int32 = 503, body~ : Bytes = b"503 Service Unavailable", headers~ : Array[(String, String)] = plain_text) -> Refusal

fnBuild a refusal. Left alone it is the 503 Service Unavailable the breaker, the shedder and the connection limiter all answer with.

let refusal : Refusal = Refusal::new()

letThe generic refusal: 503 Service Unavailable.

let unavailable : Refusal = refusal

letWhat an open breaker, a shed request and a spent connection budget answer with.

let too_many : Refusal = Refusal::new( status=429, body=b"429 Too Many Requests")

letWhat a rate-limited request answers with.

let timed_out : Refusal = Refusal::new(body=b"service timeout")

letWhat a request past its deadline answers with. timeout middleware answers 503 with this body rather than 504, so that is the default.

let too_large : Refusal = Refusal::new( status=413, body=b"413 Payload Too Large")

letWhat an over-large request body answers with.

fn Refusal::events(self : Refusal) -> Array[@moonasgi.Event]

fnThe refusal as the ASGI events that send it. A pure value, so a middleware's answer is testable without driving the async transport.