| import * as Context from "../../Context.ts"; | |
| import * as Effect from "../../Effect.ts"; | |
| import * as Layer from "../../Layer.ts"; | |
| import * as Scope from "../../Scope.ts"; | |
| import { type HttpMiddleware } from "./HttpMiddleware.ts"; | |
| import { HttpServerError } from "./HttpServerError.ts"; | |
| import { HttpServerRequest } from "./HttpServerRequest.ts"; | |
| import type { HttpServerResponse } from "./HttpServerResponse.ts"; | |
| import { appendPreResponseHandlerUnsafe } from "./internal/preResponseHandler.ts"; | |
| /** | |
| * Runs an HTTP server effect, sends the produced response with the supplied handler, and converts failures into HTTP responses. | |
| * | |
| * @category combinators | |
| * @since 4.0.0 | |
| */ | |
| export declare const toHandled: <E, R, EH, RH>(self: Effect.Effect<HttpServerResponse, E, R>, handleResponse: (request: HttpServerRequest, response: HttpServerResponse) => Effect.Effect<unknown, EH, RH>, middleware?: HttpMiddleware | undefined) => Effect.Effect<void, never, Exclude<R | RH | HttpServerRequest, Scope.Scope>>; | |
| /** | |
| * Disables automatic closing for an HTTP request scope. | |
| * | |
| * **Gotchas** | |
| * | |
| * Use only when another owner will close the scope; otherwise resources attached | |
| * to the request scope can leak. | |
| * | |
| * @category resource management | |
| * @since 4.0.0 | |
| */ | |
| export declare const scopeDisableClose: (scope: Scope.Scope) => void; | |
| /** | |
| * Returns a streaming server response that closes the request scope when the body stream exits. | |
| * | |
| * @category resource management | |
| * @since 4.0.0 | |
| */ | |
| export declare const scopeTransferToStream: (response: HttpServerResponse) => HttpServerResponse; | |
| /** | |
| * Function run with the current request and response just before the response is sent, allowing the response to be replaced or failing with `HttpServerError`. | |
| * | |
| * @category Pre-response handlers | |
| * @since 4.0.0 | |
| */ | |
| export type PreResponseHandler = (request: HttpServerRequest, response: HttpServerResponse) => Effect.Effect<HttpServerResponse, HttpServerError>; | |
| /** | |
| * Registers an additional pre-response handler for the current HTTP server request. | |
| * | |
| * @category fiber refs | |
| * @since 4.0.0 | |
| */ | |
| export declare const appendPreResponseHandler: (handler: PreResponseHandler) => Effect.Effect<void, never, HttpServerRequest>; | |
| export { | |
| /** | |
| * Registers a pre-response handler for the supplied HTTP server request. | |
| * | |
| * @category fiber refs | |
| * @since 4.0.0 | |
| */ | |
| appendPreResponseHandlerUnsafe }; | |
| /** | |
| * Runs an effect after registering a pre-response handler for the current HTTP server request. | |
| * | |
| * @category fiber refs | |
| * @since 4.0.0 | |
| */ | |
| export declare const withPreResponseHandler: { | |
| /** | |
| * Runs an effect after registering a pre-response handler for the current HTTP server request. | |
| * | |
| * @category fiber refs | |
| * @since 4.0.0 | |
| */ | |
| (handler: PreResponseHandler): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R | HttpServerRequest>; | |
| /** | |
| * Runs an effect after registering a pre-response handler for the current HTTP server request. | |
| * | |
| * @category fiber refs | |
| * @since 4.0.0 | |
| */ | |
| <A, E, R>(self: Effect.Effect<A, E, R>, handler: PreResponseHandler): Effect.Effect<A, E, R | HttpServerRequest>; | |
| }; | |
| /** | |
| * Converts an HTTP server effect into a Web `Request` handler using the supplied base context and optional middleware. | |
| * | |
| * @category converting | |
| * @since 4.0.0 | |
| */ | |
| export declare const toWebHandlerWith: <Provided, R = never, ReqR = Exclude<R, Provided | Scope.Scope | HttpServerRequest>>(context: Context.Context<Provided>) => <E>(self: Effect.Effect<HttpServerResponse, E, R>, middleware?: HttpMiddleware | undefined) => [ReqR] extends [never] ? (request: Request, context?: Context.Context<never> | undefined) => Promise<globalThis.Response> : (request: Request, context: Context.Context<ReqR>) => Promise<globalThis.Response>; | |
| /** | |
| * Converts an HTTP server effect into a Web `Request` handler using an empty base context. | |
| * | |
| * @category converting | |
| * @since 4.0.0 | |
| */ | |
| export declare const toWebHandler: <E>(self: Effect.Effect<HttpServerResponse, E, HttpServerRequest | Scope.Scope>, middleware?: HttpMiddleware | undefined) => (request: Request, context?: Context.Context<never> | undefined) => Promise<globalThis.Response>; | |
| /** | |
| * Builds a Web `Request` handler from a layer and handler factory, returning the handler with a `dispose` function for the layer scope. | |
| * | |
| * @category converting | |
| * @since 4.0.0 | |
| */ | |
| export declare const toWebHandlerLayerWith: <E, Provided, LE, R, ReqR = Exclude<R, Provided | Scope.Scope | HttpServerRequest>>(layer: Layer.Layer<Provided, LE>, options: { | |
| readonly toHandler: (context: Context.Context<Provided>) => Effect.Effect<Effect.Effect<HttpServerResponse, E, R>, LE>; | |
| readonly middleware?: HttpMiddleware | undefined; | |
| readonly memoMap?: Layer.MemoMap | undefined; | |
| }) => { | |
| readonly dispose: () => Promise<void>; | |
| readonly handler: [ReqR] extends [never] ? (request: Request, context?: Context.Context<never> | undefined) => Promise<globalThis.Response> : (request: Request, context: Context.Context<ReqR>) => Promise<globalThis.Response>; | |
| }; | |
| /** | |
| * Builds a Web `Request` handler for an HTTP server effect using a layer to provide its services, returning the handler with a `dispose` function. | |
| * | |
| * @category converting | |
| * @since 4.0.0 | |
| */ | |
| export declare const toWebHandlerLayer: <E, R, Provided, LE, ReqR = Exclude<R, Provided | Scope.Scope | HttpServerRequest>>(self: Effect.Effect<HttpServerResponse, E, R>, layer: Layer.Layer<Provided, LE>, options?: { | |
| readonly middleware?: HttpMiddleware | undefined; | |
| readonly memoMap?: Layer.MemoMap | undefined; | |
| } | undefined) => { | |
| readonly dispose: () => Promise<void>; | |
| readonly handler: [ReqR] extends [never] ? (request: Request, context?: Context.Context<never> | undefined) => Promise<globalThis.Response> : (request: Request, context: Context.Context<ReqR>) => Promise<globalThis.Response>; | |
| }; | |
| /** | |
| * Adapts a Web `Request` handler into an HTTP server effect for the current `HttpServerRequest`. | |
| * | |
| * @category converting | |
| * @since 4.0.0 | |
| */ | |
| export declare const fromWebHandler: (handler: (request: Request) => Promise<Response>) => Effect.Effect<HttpServerResponse, HttpServerError, HttpServerRequest>; | |
| //# sourceMappingURL=HttpEffect.d.ts.map |
Xet Storage Details
- Size:
- 6.24 kB
- Xet hash:
- c159903a6ae7e7adef39f453bec05f7e730bb47b67175cbf25b9018283308c98
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.