Skip to content

HttpStaticServer

Serves static files for Effect HTTP applications.

HttpStaticServer turns request paths into file responses under a configured root directory. It can be used as an application value or mounted onto an HttpRouter, and it handles index files, optional single-page application fallback, MIME type headers, cache-control headers, byte ranges, and conditional 304 Not Modified responses.

2 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Creates an HttpApp that serves files from a directory.

Signature

declare const make: (options: {
readonly cacheControl?: string;
readonly index?: string;
readonly mimeTypes?: Record<string, string>;
readonly root: string;
readonly spa?: boolean;
}) => Effect.Effect<
Effect.Effect<
HttpServerResponse.HttpServerResponse,
HttpServerError.HttpServerError,
HttpServerRequest.HttpServerRequest
>,
PlatformError,
FileSystem.FileSystem | Path.Path | HttpPlatform.HttpPlatform
>;

Layers

layer

Added in v4.0.0 Source

Creates a layer that mounts static files on an HttpRouter.

Signature

declare function layer(options: {
readonly cacheControl?: string;
readonly index?: string;
readonly mimeTypes?: Record<string, string>;
readonly prefix?: string;
readonly root: string;
readonly spa?: boolean;
}): Layer<never, PlatformError, FileSystem | Path | HttpRouter | HttpPlatform>;