Function serveFile

  • Resolves a Response with the requested file as the body.

    Parameters

    • req: Request

      The server request context used to cleanup the file handle.

    • filePath: string

      Path of the file to serve.

    • Optionaloptions: ServeFileOptions

      Additional options.

    Returns Promise<Response>

    A response for the request.

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

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