Skip to content

InterceptRespond

[Source]

Returned by a request interceptor to short-circuit with an HTTP response.

The handler is not created — the interceptor's response goes directly to the client. Use for rejections (401, 403, 413), cached responses (304), redirects (301, 302), or any case where the handler isn't needed.

Build the response with set_header(), add_header(), and the status and body provided at construction.

// Reject unauthorized
InterceptRespond(stallion.StatusUnauthorized, "Unauthorized")

// Short-circuit with custom headers
InterceptRespond(stallion.StatusTooManyRequests, "Rate limited")
  .> set_header("retry-after", "60")
class ref InterceptRespond

Constructors

create

[Source]

new ref create(
  status: Status val,
  body: (String val | Array[U8 val] val))
: InterceptRespond ref^

Parameters

Returns


Public Functions

set_header

[Source]

Set a response header, replacing any existing header with the same name.

The name is lowercased for consistency with HTTP's case-insensitive header names.

fun ref set_header(
  name: String val,
  value: String val)
: None val

Parameters

Returns


add_header

[Source]

Add a response header without removing existing entries.

The name is lowercased for consistency. Use for multi-value headers like Set-Cookie.

fun ref add_header(
  name: String val,
  value: String val)
: None val

Parameters

Returns