diff --git a/src/handler.ts b/src/handler.ts index 51b7493..d7d44d2 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -2,6 +2,7 @@ import { ControlFlow, Break, Continue } from "./control_flow" // Typescript lacks shadowing, so code sometimes can be stupid to avoid it +type Mapper = (inp: Handler) => Handler export type HandlerFn = (req: C, next: Endpoint) => Promise> export type InputHandler = HandlerFn | Handler @@ -35,6 +36,10 @@ export class Handler { this.fn = fn } + use(f: Mapper): Handler { + return f(this) + } + then(next: InputHandler): Handler { return new Handler(then(this, next)) }