Files
SnowLuma/.pnpm-store/v11/files/45/28b31c03b5c44f7d5e63d47cafb38dbde287cb96f929c5d2c8be739574959ec5eed8c2bbdaa2a99326ef5fd4b66759b2ff2901df0ce3a63acd652b1f890ad7
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

41 lines
1.6 KiB
Plaintext

import { MiddlewareHandler } from "../../types.js";
//#region src/middleware/etag/index.d.ts
type ETagOptions = {
retainedHeaders?: string[];
weak?: boolean;
generateDigest?: (body: Uint8Array<ArrayBuffer>) => ArrayBuffer | Promise<ArrayBuffer>;
};
/**
* Default headers to pass through on 304 responses. From the spec:
* > The response must not contain a body and must include the headers that
* > would have been sent in an equivalent 200 OK response: Cache-Control,
* > Content-Location, Date, ETag, Expires, and Vary.
*/
export declare const RETAINED_304_HEADERS: string[];
/**
* ETag Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/etag}
*
* @param {ETagOptions} [options] - The options for the ETag middleware.
* @param {boolean} [options.weak=false] - Define using or not using a weak validation. If true is set, then `W/` is added to the prefix of the value.
* @param {string[]} [options.retainedHeaders=RETAINED_304_HEADERS] - The headers that you want to retain in the 304 Response.
* @param {function(Uint8Array): ArrayBuffer | Promise<ArrayBuffer>} [options.generateDigest] -
* A custom digest generation function. By default, it uses 'SHA-1'
* This function is called with the response body as a `Uint8Array` and should return a hash as an `ArrayBuffer` or a Promise of one.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use('/etag/*', etag())
* app.get('/etag/abc', (c) => {
* return c.text('Hono is hot')
* })
* ```
*/
export declare const etag: (options?: ETagOptions) => MiddlewareHandler;
//#endregion
export {};