sigildocs

(sigil cli serve)

(sigil cli serve) - Static file server for local web-app testing.

Backs the sigil serve subcommand. It serves a directory of static files over HTTP for local testing of a Sigil browser app: point it at the web build output (build/web/ by default) and open the printed URL.

Built on (sigil http) (server + mime) rather than a hand-rolled socket loop, so MIME types (notably .wasm -> application/wasm), Content-Length, and binary-safe transfer come from the shared library. Files are read as bytevectors so binary assets (the .wasm) are served byte-accurately.

This module is loaded lazily by the CLI (it pulls in (sigil http), which is not present in the bootstrap CLI). See serve-handler in (sigil cli).

Exports

Strip every leading "/" so a request path is always treated as relative to the served root (an absolute second arg would otherwise make path-join ignore the root entirely).

resolve-fileprocedure

Resolve a request path to a readable file under root, or #f. Directories resolve to their index.html. The normalized target must stay within root (path-normalize collapses ".." so traversal is rejected).

file-responseprocedure

Build the response for a resolved file. Compression is delegated to the shared (sigil http) helper http-response-gzip, which negotiates against the request's Accept-Encoding and only compresses worthwhile types.

Build a handler that serves static files from root.

serve-mainprocedure

Serve root over HTTP on host:port. Blocks until interrupted.