Interface for a body parser.

interface BodyParserInterface {
    attachTo?: (app: ZibriApplication) => void | Promise<void>;
    contentType: MimeType;
    parseFromHttpClientResponse: (
        res: HttpClientResponse,
        bodyMetadata: BodyMetadata,
    ) => unknown;
    parseFromHttpRequest: (
        req: HttpRequest,
        bodyMetadata: BodyMetadata,
    ) => unknown;
    parseFromWebsocketRequest: (
        req: WebsocketRequest,
        bodyMetadata: BodyMetadata,
    ) => unknown;
}

Implemented by

Properties

attachTo?: (app: ZibriApplication) => void | Promise<void>

Attaches the body parser to the Zibri application.

contentType: MimeType

The content type that can be handled by this parser.

parseFromHttpClientResponse: (
    res: HttpClientResponse,
    bodyMetadata: BodyMetadata,
) => unknown

Parses the body of the http response.

parseFromHttpRequest: (req: HttpRequest, bodyMetadata: BodyMetadata) => unknown

Parses the body of the http request.

parseFromWebsocketRequest: (
    req: WebsocketRequest,
    bodyMetadata: BodyMetadata,
) => unknown

Parses the body of the websocket request.