Skip to content

HttpApp

14 exports Added in v1.0.0 Source

Combinators

toHandled

Added in v1.0.0 Source

Signature

declare function toHandled<E, R, _, EH, RH>(
  self: Default<E, R>,
  handleResponse: (request: HttpServerRequest, response: HttpServerResponse) => Effect<_, EH, RH>,
  middleware?: HttpMiddleware,
): Effect<void, never, HttpServerRequest | Exclude<R, Scope> | Exclude<RH, Scope>>;

Conversions

Signature

declare function fromWebHandler(
  handler: (request: Request) => Promise<Response>,
): Default<HttpServerError>;

toWebHandler

Added in v1.0.0 Source

Signature

declare const toWebHandler: <E>(
  self: Default<E, Scope.Scope>,
  middleware?: HttpMiddleware,
) => (request: Request, context?: Context.Context<never>) => Promise<Response>;

Signature

declare function toWebHandlerLayer<E, R, RE>(
  self: Default<E, Scope | R>,
  layer: Layer<R, RE>,
  options?: {
    readonly memoMap?: MemoMap;
    readonly middleware?: HttpMiddleware;
  },
): {
  readonly dispose: () => Promise<void>;
  readonly handler: (request: Request, context?: Context<never>) => Promise<Response>;
};

Signature

declare function toWebHandlerLayerWith<E, R, RE, EX>(
  layer: Layer<R, RE>,
  options: {
    readonly memoMap?: MemoMap;
    readonly middleware?: HttpMiddleware;
    readonly toHandler: (
      runtime: Runtime<R>,
    ) => Effect<Effect<HttpServerResponse, E, Scope | HttpServerRequest | R>, EX>;
  },
): {
  readonly dispose: () => Promise<void>;
  readonly handler: (request: Request, context?: Context<never>) => Promise<Response>;
};

Signature

declare function toWebHandlerRuntime<R>(
  runtime: Runtime<R>,
): <E>(
  self: Default<E, Scope | R>,
  middleware?: HttpMiddleware,
) => (request: Request, context?: Context<never>) => Promise<Response>;

Fiber Refs

Signature

declare const appendPreResponseHandler: (handler: PreResponseHandler) => Effect.Effect<void>;

Signature

declare const currentPreResponseHandlers: FiberRef.FiberRef<Option.Option<PreResponseHandler>>;

Signature

declare const withPreResponseHandler: (handler: PreResponseHandler) => <A, E, R>(self: HttpApp<A, E, R>) => HttpApp<A, E, R> & <A, E, R>(self: HttpApp<A, E, R>, handler: PreResponseHandler) => HttpApp<A, E, R>

Models

Default type

Added in v1.0.0 Source

Signature

type Default<E = never, R = never> = HttpApp<ServerResponse.HttpServerResponse, E, R>;

HttpApp type

Added in v1.0.0 Source

Signature

type HttpApp<A = ServerResponse.HttpServerResponse, E = never, R = never> = Effect.Effect<
  A,
  E,
  R | ServerRequest.HttpServerRequest
>;

PreResponseHandler type

Added in v1.0.0 Source

Signature

type PreResponseHandler = (
  request: ServerRequest.HttpServerRequest,
  response: ServerResponse.HttpServerResponse,
) => Effect.Effect<ServerResponse.HttpServerResponse, ServerError.ResponseError>;

Scope

If you want to finalize the http request scope elsewhere, you can use this function to eject from the default scope closure.

Signature

declare function ejectDefaultScopeClose(scope: Scope): void;

Signature

declare function unsafeEjectStreamScope(response: HttpServerResponse): HttpServerResponse;