Files
SnowLuma/.pnpm-store/v11/files/48/8f071e22fb8e4f9e519fecc0bbc56a47469b22c86f06a982c8ce665a8d94debe7b0d0c950dc5693e686193f69e86bbd6e07e30ccab320ec1c2eba1e98aa97f
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

47 lines
1.7 KiB
Plaintext

import { MiddlewareHandler } from "../../types.js";
import { Context } from "../../context.js";
//#region src/middleware/mount/index.d.ts
type ApplicationHandler = (request: Request, ...args: any) => Response | Promise<Response>;
type MountOptionHandler = (c: Context) => unknown;
type MountReplaceRequest = (originalRequest: Request) => Request;
type MountOptions = MountOptionHandler | {
optionHandler?: MountOptionHandler;
replaceRequest?: MountReplaceRequest | false;
};
/**
* `mount()` allows you to mount applications built with other frameworks into your Hono application.
*
* @see {@link https://hono.dev/docs/api/hono#mount}
*
* @param {Function} applicationHandler - other Request Handler
* @param {MountOptions} [options] - options of `mount()`
* @returns {MiddlewareHandler} handler to register with `app.all()`
*
* @example
* ```ts
* import { Router as IttyRouter } from 'itty-router'
* import { Hono } from 'hono'
* import { mount } from 'hono/mount'
* // Create itty-router application
* const ittyRouter = IttyRouter()
* // GET /itty-router/hello
* ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
*
* const app = new Hono()
* app.all('/itty-router/*', mount(ittyRouter.handle))
* ```
*
* @example
* ```ts
* const app = new Hono()
* // Send the request to another application without modification.
* app.all('/app/*', mount(anotherApp, {
* replaceRequest: (req) => req,
* }))
* ```
*/
export declare const mount: (applicationHandler: ApplicationHandler, options?: MountOptions) => MiddlewareHandler;
//#endregion
export type { ApplicationHandler, MountOptionHandler, MountOptions, MountReplaceRequest };
export {};