Http module

unauthorized

procedure · 1 overloadSource

An Http_Error with status 401, for when the caller has not authenticated. Add WWW-Authenticate with with_header. format and args make the detail text as tprint does, in the temporary allocator.

Example
error := with_header(unauthorized("a token is required"), "WWW-Authenticate", "Bearer");

assert(error.status == 401);
assert(error.headers.count == 1);

Doesn't run in the browser (skipped on wasm).

unauthorized :: (format := "", args: ..Any) -> Http_Error

An Http_Error with status 401, for when the caller has not authenticated. Add WWW-Authenticate with with_header. format and args make the detail text as tprint does, in the temporary allocator.

Parameters

format := ""
args: ..Any

Returns

Example
error := with_header(unauthorized("a token is required"), "WWW-Authenticate", "Bearer");

assert(error.status == 401);
assert(error.headers.count == 1);

Doesn't run in the browser (skipped on wasm).

See also