import { HttpOperationResponse, OpraException, OpraHttpError } from '@opra/common'; import { AssetCache, kAssetCache } from '@opra/core'; import type { HttpAdapter } from './http-adapter.js'; import { HttpContext } from './http-context.js'; /** * @namespace */ export declare namespace HttpHandler { /** * @interface ResponseArgs */ interface ResponseArgs { statusCode: number; contentType?: string; operationResponse?: HttpOperationResponse; body?: any; projection?: string[] | '*'; } } /** * HttpHandler is responsible for processing incoming HTTP requests. * It handles request parsing, interceptor execution, and response generation. */ export declare class HttpHandler { readonly adapter: HttpAdapter; protected [kAssetCache]: AssetCache; onError?: (context: HttpContext, error: OpraException) => void | Promise; constructor(adapter: HttpAdapter); /** * Main HTTP request handler. * * @param context - The HTTP execution context. * @returns A promise that resolves when the request is handled. * @protected */ handleRequest(context: HttpContext): Promise; /** * Parses the HTTP request, including parameters and content type. * * @param context - The HTTP execution context. * @returns A promise that resolves when the request is parsed. */ parseRequest(context: HttpContext): Promise; /** * Parses various HTTP parameters (cookies, headers, path, query). * * @param context - The HTTP execution context. * @returns A promise that resolves when parameters are parsed. * @throws {@link BadRequestError} If parameter validation fails. * @protected */ protected _parseParameters(context: HttpContext): Promise; /** * Parses and validates the request content type. * * @param context - The HTTP execution context. * @returns A promise that resolves when content type is parsed. * @throws {@link BadRequestError} If the content type is invalid or missing. * @protected */ protected _parseContentType(context: HttpContext): Promise; /** * * @param context * @protected */ protected _executeRequest(context: HttpContext): Promise; /** * Sends an HTTP response back to the client. * * @param context - The HTTP execution context. * @param responseValue - The value to be sent in the response body. * @returns A promise that resolves when the response is sent. */ sendResponse(context: HttpContext, responseValue?: any): Promise; protected _sendErrorResponse(context: HttpContext): Promise; /** * Sends the document schema as a JSON response. * * @param context - The HTTP execution context. * @returns A promise that resolves when the schema is sent. */ sendDocumentSchema(context: HttpContext): Promise; /** * Determines the response arguments (status code, content type, etc.) for a given response value. * * @param context - The HTTP execution context. * @param body - The response body. * @returns The determined response arguments. * @throws {@link InternalServerError} If response configuration is missing or invalid. * @protected */ protected _determineResponseArgs(context: HttpContext, body: any): HttpHandler.ResponseArgs; protected _wrapExceptions(exceptions: any[]): OpraHttpError[]; }