sigildocs

(sigil web static)

(sigil web static) - Static File Serving

Provides static file serving with MIME type detection and security features to prevent directory traversal attacks.

Example: (define static-handler (make-static-handler "public/"))

;; Serves files from public/ directory ;; Request to /css/style.css serves public/css/style.css

Exports

safe-path?procedure

Check if a path is safe (no directory traversal) Returns #t if path doesn't contain dangerous components

serve-fileprocedure

Serve a single file with appropriate headers Returns http-response or #f if file doesn't exist

Check if MIME type is text-based

Create a static file handler for a directory base-dir: root directory for static files options: optional alist with:

  • index: index file name (default: "index.html")
  • prefix: URL prefix to strip (default: "")