method IStaticFiles.serve
Since 0.1.0
IStaticFiles.serve(ctx: IRequestContext): Promise<HandlerResult>

Serves the static file addressed by the request context, applying the same conditional-request, Range, and encoding negotiation the mounted routes use — this and the route handler are one implementation, so both honour the plugin's configuration identically.

Answers 404 rather than throwing when the path resolves to nothing, and when the runtime provides no file system (edge platforms), since a missing asset is a not-found and not an error.

Parameters

ctx: IRequestContext

The request context

Return Type

Promise<HandlerResult>

The handler result for the resolved file

Usage

import { type IStaticFiles } from "static-plugin/src/index.ts";