Http module

Middleware

typeSource

A request filter: log, check a token, add headers, or answer itself without calling next.

Example
require_token :: (request: *Request, next: Next) -> Response {
    token, found := header(request, "Authorization");
    if !found return error_response(request, unauthorized("a token is required"));

    return next(request);
}

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

Middleware :: #type (request: *Request, next: Next) -> Response

See also