InterceptRespond¶
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")
Constructors¶
create¶
Parameters¶
Returns¶
- InterceptRespond ref^
Public Functions¶
set_header¶
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.
Parameters¶
Returns¶
- None val
add_header¶
Add a response header without removing existing entries.
The name is lowercased for consistency. Use for multi-value headers like
Set-Cookie.
Parameters¶
Returns¶
- None val