Middleware
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Middleware = (
req,next) =>Promise<HttpResponse> |HttpResponse
Defined in: src/http/Route.ts:30
Per-request hook that runs around a handler. Receives the request
and a next() thunk; either short-circuit by returning your own
response, or call next() and pass its result through (optionally
wrapped, decorated, or re-thrown).
Examples (all shipped in src/http/middleware/):
BearerTokenAuth({ tokens })— checksAuthorization: Bearer, short-circuits with 401 on mismatch.IpAllowlist({ allow })— checksremoteAddress(or a configured extractor) against a CIDR list, short-circuits with 403 if not allowed.
Throwing HttpError(status, msg) is the idiomatic short-circuit:
the global error handler catches it and emits the right response.
Parameters
Section titled “Parameters”() => Promise<HttpResponse>
Returns
Section titled “Returns”Promise<HttpResponse> | HttpResponse