Skip to main content
Home

@std/http@1.0.22
Built and signed on GitHub Actions

Utilities for building HTTP servers

This package works with DenoIt is unknown whether this package works with Bun
This package works with Deno
It is unknown whether this package works with Bun
JSR Score
94%
Published
4 weeks ago (1.0.22)
function serveFile
serveFile(
req: Request,
filePath: string,
options?: ServeFileOptions,
): Promise<Response>

Resolves a Response with the requested file as the body.

Examples

Usage

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

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

Parameters

The server request context used to cleanup the file handle.

filePath: string

Path of the file to serve.

optional
options: ServeFileOptions

Additional options.

Return Type

A response for the request.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/http

Import symbol

import { serveFile } from "@std/http";
or

Import directly with a jsr specifier

import { serveFile } from "jsr:@std/http";

Add Package

bunx jsr add @std/http

Import symbol

import { serveFile } from "@std/http";