-
-
Notifications
You must be signed in to change notification settings - Fork 664
Closed
Description
I am doing another iteration on this. The primary goal is to support pre-parsed headers in handlers. However, just doing that seems a bit wasteful and I'm hoping to take the interface one step forward:
I am thinking of something the following lines:
interface Controller {
pause () : void;
resume () : void;
abort(err: Error) : void;
get aborted () : boolean;
get reason() : Error;
}
type Headers = Record<string, string | string[]>;
type Trailers = Record<string, string | string[]>;
interface Handler {
onRequestStart(controller: Controller): void;
// onRequestHeaders(controller: Controller, headers: Headers): Headers;
// onRequestData(controller: Controller: chunk: Buffer): Buffer;
// onRequestTrailers(controller: Controller: chunk, trailers: Trailers): Trailers;
// onRequestEnd(controller: Controller): void;
// onRequestError(controller: Controller, error: Error): void;
onResponseStart(controller: Controller, statusCode: number, statusMessage?: string) : void;
onResponseHeaders(controller: Controller, headers: Headers): void;
onResponseData(controller: Controller, chunk: Buffer): void;
onResponseTrailers(controller: Controller, trailers: Trailers): void;
onResponseEnd(controller: Controller): void;
onResponseError(controller: Controller, err: Error): void;
}
Metadata
Metadata
Assignees
Labels
No labels