import { type HttpResponseLike } from "../http/index.js"; import type { HttpLayer } from "../layer/index.js"; import type { HttpService } from "../service/index.js"; import { type Handler } from "./handler.js"; import { MethodFilter } from "./method-filter.js"; /** * Registers a handler function to be executed when a specified method * matches the provided filter. */ export declare const on: (filter: MethodFilter, handler: Handler) => MethodRouter; /** * Creates a new MethodRouter instance configured with a fallback handler and * skips the 'Allow' header. */ export declare const any: (handler: Handler) => MethodRouter; /** * Shortcut methods for creating {@link MethodRouter}s for a given method. */ export declare const m: { connect: (handler: Handler) => MethodRouter; delete: (handler: Handler) => MethodRouter; get: (handler: Handler) => MethodRouter; head: (handler: Handler) => MethodRouter; options: (handler: Handler) => MethodRouter; patch: (handler: Handler) => MethodRouter; post: (handler: Handler) => MethodRouter; put: (handler: Handler) => MethodRouter; trace: (handler: Handler) => MethodRouter; }; /** * Represents a router for mapping HTTP methods and their handlers to specific * endpoints. * * The class supports various HTTP methods and allows defining handlers for GET, * POST, PUT, DELETE, HEAD, OPTIONS, PATCH, TRACE, and CONNECT methods. It also * supports a fallback mechanism and the ability to apply middleware layers to * all endpoints. */ export declare class MethodRouter implements HttpService { private getEndpoint; private headEndpoint; private deleteEndpoint; private optionsEndpoint; private patchEndpoint; private postEndpoint; private putEndpoint; private traceEndpoint; private connectEndpoint; private fallbackEndpoint; private allowHeader; private constructor(); static default(): MethodRouter; /** * Registers a handler function for specific HTTP methods based on the * provided filter. * * @param filter - the filter that determines which methods the handler * should be applied to. * @param handler - the handler function to be executed for the specified * methods and filter. */ on(filter: MethodFilter, handler: Handler): this; /** * Registers an HTTP CONNECT request handler. * * @param handler - the handler function to be executed for this method. */ connect(handler: Handler): this; /** * Registers an HTTP DELETE request handler. * * @param handler - the handler function to be executed for this method. */ delete(handler: Handler): this; /** * Registers an HTTP GET request handler. * * @param handler - the handler function to be executed for this method. */ get(handler: Handler): this; /** * Registers an HTTP HEAD request handler. * * @param handler - the handler function to be executed for this method. */ head(handler: Handler): this; /** * Registers an HTTP OPTIONS request handler. * * @param handler - the handler function to be executed for this method. */ options(handler: Handler): this; /** * Registers an HTTP PATCH request handler. * * @param handler - the handler function to be executed for this method. */ patch(handler: Handler): this; /** * Registers an HTTP POST request handler. * * @param handler - the handler function to be executed for this method. */ post(handler: Handler): this; /** * Registers an HTTP PUT request handler. * * @param handler - the handler function to be executed for this method. */ put(handler: Handler): this; /** * Registers an HTTP TRACE request handler. * * @param handler - the handler function to be executed for this method. */ trace(handler: Handler): this; /** * Registers a fallback handler which is called if no other method matches. * * @param handler - the handler function to be executed for this method. */ fallback(handler: Handler): this; /** * Applies the specified layer to all endpoint mappings within this router. * * @param layer - the middleware to be applied to the endpoints. */ layer(layer: HttpLayer): MethodRouter; private static mergeInner; private invokeMethod; private setEndpoint; }