import { type HeaderMap, HeaderValue, type HttpRequest, type HttpResponse } from "../http/index.js"; import type { HttpLayer } from "../layer/index.js"; import type { HttpService } from "../service/index.js"; export type WithHeaders = { headers: HeaderMap; }; export type MakeHeaderValue = HeaderValue | string | null | ((message: T) => HeaderValue | string | null); /** * A layer that sets a specific HTTP response header. * * @example * ```ts * import { SetResponseHeaderLayer } from "@taxum/core/middleware/set-header"; * import { m, Router } from "@taxum/core/routing"; * * const router = new Router() * .route("/", m.get(() => "Hello World)) * .layer(new SetResponseHeaderLayer("Content-Type", "text/plain")); * ``` */ export declare class SetResponseHeaderLayer implements HttpLayer { private readonly mode; private readonly name; private readonly make; private constructor(); /** * Creates a new {@link SetResponseHeaderLayer}. * * If a previous value exists for the same header, it is removed and * replaced with the new header value. */ static overriding(name: string, make: MakeHeaderValue): SetResponseHeaderLayer; /** * Creates a new {@link SetResponseHeaderLayer}. * * The new header is always added, preserving any existing values. If * previous values exist, the header will have multiple values. */ static appending(name: string, make: MakeHeaderValue): SetResponseHeaderLayer; /** * Creates a new {@link SetResponseHeaderLayer}. * * If a previous value exists for the header, the new value is not inserted. */ static ifNotPresent(name: string, make: MakeHeaderValue): SetResponseHeaderLayer; layer(inner: HttpService): HttpService; } /** * A layer that sets a specific HTTP request header. * * @example * ```ts * import { SetRequestHeaderLayer } from "@taxum/core/middleware/set-header"; * import { m, Router } from "@taxum/core/routing"; * * const router = new Router() * .route("/", m.get(() => "Hello World)) * .layer(new SetRequestHeaderLayer("Content-Type", "text/plain")); * ``` */ export declare class SetRequestHeaderLayer implements HttpLayer { private readonly mode; private readonly name; private readonly make; private constructor(); /** * Creates a new {@link SetRequestHeaderLayer}. * * If a previous value exists for the same header, it is removed and * replaced with the new header value. */ static overriding(name: string, make: MakeHeaderValue): SetRequestHeaderLayer; /** * Creates a new {@link SetRequestHeaderLayer}. * * The new header is always added, preserving any existing values. If * previous values exist, the header will have multiple values. */ static appending(name: string, make: MakeHeaderValue): SetRequestHeaderLayer; /** * Creates a new {@link SetRequestHeaderLayer}. * * If a previous value exists for the header, the new value is not inserted. */ static ifNotPresent(name: string, make: MakeHeaderValue): SetRequestHeaderLayer; layer(inner: HttpService): HttpService; }