import * as Context from "../Context.ts";
import * as Effect from "../Effect.ts";
import * as Layer from "../Layer.ts";
import type { Predicate } from "../Predicate.ts";
import type { CompressionAlgorithm } from "./HttpPlatform.ts";
import { HttpPlatform } from "./HttpPlatform.ts";
import { HttpServerRequest } from "./HttpServerRequest.ts";
import * as Request from "./HttpServerRequest.ts";
import * as Response from "./HttpServerResponse.ts";
import type { HttpServerResponse } from "./HttpServerResponse.ts";
/**
 * Middleware that transforms an HTTP server app effect into another HTTP server app effect.
 *
 * @stability unstable
 * @category models
 * @since 4.0.0
 */
export interface HttpMiddleware {
    <E, R>(self: Effect.Effect<HttpServerResponse, E, R | HttpServerRequest>): Effect.Effect<HttpServerResponse, any, any>;
}
/**
 * Namespace containing types associated with `HttpMiddleware`.
 *
 * @stability unstable
 * @since 4.0.0
 */
export declare namespace HttpMiddleware {
    /**
     * Callable type representing middleware already specialized to a particular transformed app type.
     *
     * @stability unstable
     * @category models
     * @since 4.0.0
     */
    interface Applied<A extends Effect.Effect<HttpServerResponse, any, any>, E, R> {
        (self: Effect.Effect<HttpServerResponse, E, R>): A;
    }
}
/**
 * Defines an `HttpMiddleware` while preserving its precise type.
 *
 * @stability unstable
 * @category constructors
 * @since 4.0.0
 */
export declare const make: <M extends HttpMiddleware>(middleware: M) => M;
/**
 * Runs an effect with HTTP response logging disabled for the current server request.
 *
 * @stability unstable
 * @category logging
 * @since 4.0.0
 */
export declare const withLoggerDisabled: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R | HttpServerRequest>;
/**
 * Context reference for a predicate that disables server-side tracing for matching requests.
 *
 * @stability unstable
 * @category services
 * @since 4.0.0
 */
export declare const TracerDisabledWhen: Context.Reference<Predicate<HttpServerRequest>>;
/**
 * Creates a layer that disables server-side tracing for requests whose URL exactly matches one of the supplied URLs.
 *
 * @stability unstable
 * @category layers
 * @since 4.0.0
 */
export declare const layerTracerDisabledForUrls: (urls: ReadonlyArray<string>) => Layer.Layer<never>;
/**
 * Context reference for generating server span names from HTTP server requests.
 *
 * **Details**
 *
 * Defaults to the request method unchanged.
 *
 * @stability unstable
 * @category services
 * @since 4.0.0
 */
export declare const SpanNameGenerator: Context.Reference<(request: HttpServerRequest) => string>;
/**
 * Context reference for filtering request and response headers added to server spans.
 *
 * **Details**
 *
 * Header capture is opt-in: the default filter records no headers. Captured
 * headers listed in `Headers.CurrentRedactedNames` are recorded as `<redacted>`.
 *
 * @stability unstable
 * @category services
 * @since 4.0.0
 */
export declare const TracerHeaderFilter: Context.Reference<(headerName: string, phase: "request" | "response") => boolean>;
/**
 * Middleware that logs sent HTTP responses with request method, request URL, and response status annotations.
 *
 * @stability unstable
 * @category logging
 * @since 4.0.0
 */
export declare const logger: <E, R>(httpApp: Effect.Effect<HttpServerResponse, E, HttpServerRequest | R>) => Effect.Effect<HttpServerResponse, E, HttpServerRequest | R>;
/**
 * Middleware that creates a server trace span for each request and records request and response HTTP attributes.
 *
 * @stability unstable
 * @category tracing
 * @since 4.0.0
 */
export declare const tracer: <E, R>(httpApp: Effect.Effect<HttpServerResponse, E, HttpServerRequest | R>) => Effect.Effect<HttpServerResponse, E, HttpServerRequest | R>;
/**
 * Middleware that trusts `X-Forwarded-Host` and `X-Forwarded-For`, updating the request host header and remote address.
 *
 * @stability unstable
 * @category proxying
 * @since 4.0.0
 */
export declare const xForwardedHeaders: <E, R>(httpApp: Effect.Effect<HttpServerResponse, E, R | HttpServerRequest>) => Effect.Effect<HttpServerResponse, E, R | HttpServerRequest>;
/**
 * Middleware that parses the current request URL's search parameters and provides them as `ParsedSearchParams`.
 *
 * @stability unstable
 * @category parsing
 * @since 4.0.0
 */
export declare const searchParamsParser: <E, R>(httpApp: Effect.Effect<HttpServerResponse, E, R>) => Effect.Effect<Response.HttpServerResponse, E, HttpServerRequest | Exclude<R, Request.ParsedSearchParams>>;
/**
 * Middleware that handles CORS preflight requests and adds configured CORS headers to HTTP responses.
 *
 * @stability unstable
 * @category middleware
 * @since 4.0.0
 */
export declare const cors: (options?: {
    readonly allowedOrigins?: ReadonlyArray<string> | Predicate<string> | undefined;
    readonly allowedMethods?: ReadonlyArray<string> | undefined;
    readonly allowedHeaders?: ReadonlyArray<string> | undefined;
    readonly exposedHeaders?: ReadonlyArray<string> | undefined;
    readonly maxAge?: number | undefined;
    readonly credentials?: boolean | undefined;
}) => <E, R>(httpApp: Effect.Effect<HttpServerResponse, E, R>) => Effect.Effect<HttpServerResponse, E, R | HttpServerRequest>;
/**
 * Middleware that compresses HTTP response bodies based on the request's
 * `Accept-Encoding` header.
 *
 * **Details**
 *
 * Content negotiation follows RFC 9110: the first algorithm in server
 * preference order that the client accepts with a positive q-value and the
 * platform supports is used. When no algorithm is acceptable the response is
 * sent uncompressed.
 *
 * The body transform is performed by the `HttpPlatform` service.
 *
 * Responses are skipped when the status is 1xx, 204, 206, or 304, when a
 * `Content-Encoding` is already present, when `Cache-Control: no-transform`
 * is set, when the content type is absent or not compressible, when a known
 * body length is below `minSize`, or when the body is empty or `FormData`. A
 * response carrying `Content-Encoding: identity` opts out of compression and
 * has the header stripped before sending.
 *
 * `Vary: Accept-Encoding` is set on every response that was eligible by
 * status and content type, including ones skipped by negotiation or
 * `minSize`.
 *
 * Do not combine this middleware with Deno's automatic response compression.
 * On edge runtimes that already apply automatic compression, the middleware
 * is unnecessary. Platforms backed by Web `CompressionStream` also cannot
 * explicitly flush each input chunk, so incremental delivery depends on the
 * runtime's implementation.
 *
 * **Gotchas**
 *
 * Compression can expose secrets through BREACH-style attacks when one
 * response contains both secret data and attacker-controlled input and an
 * attacker can observe the compressed response length. For affected routes,
 * disable compression with `Content-Encoding: identity` or
 * `Cache-Control: no-transform`, or use `compressible` to restrict which
 * response content types can be compressed.
 *
 * @stability unstable
 * @category compression
 * @since 4.0.0
 */
export declare const compression: (options?: {
    /**
     * Server preference order. Negotiation picks the first accepted algorithm
     * supported by the platform. Defaults to `["br", "gzip", "deflate"]`;
     * `zstd` must be explicitly opted into.
     */
    readonly algorithms?: ReadonlyArray<CompressionAlgorithm> | undefined;
    /**
     * Minimum body size in bytes when the length is known. Unknown-length bodies
     * are always compressed. Defaults to `1024`.
     */
    readonly minSize?: number | undefined;
    /** Replaces the default content-type predicate. */
    readonly compressible?: ((contentType: string) => boolean) | undefined;
    /** Per-algorithm levels. Platforms without a level knob ignore them. */
    readonly levels?: {
        readonly gzip?: number | undefined;
        readonly deflate?: number | undefined;
        readonly br?: number | undefined;
        readonly zstd?: number | undefined;
    } | undefined;
} | undefined) => <E, R>(httpApp: Effect.Effect<HttpServerResponse, E, R>) => Effect.Effect<HttpServerResponse, E, R | HttpServerRequest | HttpPlatform>;
//# sourceMappingURL=HttpMiddleware.d.ts.map