(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?procedureCheck if a path is safe (no directory traversal) Returns #t if path doesn't contain dangerous components
serve-fileprocedureServe a single file with appropriate headers. Returns an http-response, or #f if the file doesn't exist.
An optional request may be passed as a second argument. When it carries a Range: header, the file is served with byte-range support via http-response/file — a satisfiable range yields 206 Partial Content, an unsatisfiable one 416 Range Not Satisfiable. Without a Range header (or request) the whole file is returned as 200 OK, now advertising Accept-Ranges: bytes so clients know ranges are honored.
text-mime-type?procedureCheck if MIME type is text-based
make-static-handlerprocedureCreate 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: "")