serveFile

import { serveFile } from "jsr:@ende/http/unstable-file-server";

function ยท experimental

async function serveFile(req: Request, filePath: string, options?: ServeFileOptions): Promise<Response>

Resolves a Response with the requested file as the body.

req: Request

The server request context used to cleanup the file handle.

filePath: string

Path of the file to serve.

options?: ServeFileOptions

Additional options.

Returns

A response for the request.

Example: Usage

import { serveFile } from "@ende/http/file-server";

Ende.serve((req) => {
  return serveFile(req, "README.md");
});

Source