EdgeAIG's picture
download
raw
4.48 kB
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 { 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.
*
* @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`.
*
* @since 4.0.0
*/
export declare namespace HttpMiddleware {
/**
* Callable type representing middleware already specialized to a particular transformed app type.
*
* @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.
*
* @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.
*
* @category Logger
* @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.
*
* @category Tracer
* @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.
*
* @category Tracer
* @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.
*
* @category Tracer
* @since 4.0.0
*/
export declare const SpanNameGenerator: Context.Reference<(request: HttpServerRequest) => string>;
/**
* Middleware that logs sent HTTP responses with request method, request URL, and response status annotations.
*
* @category Logger
* @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.
*
* @category Tracer
* @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.
*
* @category Proxying
* @since 4.0.0
*/
export declare const xForwardedHeaders: <E, R>(httpApp: Effect.Effect<Response.HttpServerResponse, E, HttpServerRequest | R>) => Effect.Effect<Response.HttpServerResponse, E, HttpServerRequest | R>;
/**
* Middleware that parses the current request URL's search parameters and provides them as `ParsedSearchParams`.
*
* @category search params
* @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.
*
* @category CORS
* @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>;
//# sourceMappingURL=HttpMiddleware.d.ts.map

Xet Storage Details

Size:
4.48 kB
·
Xet hash:
d5f0814af7a2f66b8e40d83f9e56086df44c305a76e0e6df5d10b5994059ed1c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.