fast-twitch.middlewares.file
Complete generated reference for fast-twitch.middlewares.file
Usage and execution boundary
Reads a native filesystem root for GET/HEAD requests. Missing/rejected paths fall through to the application handler. Percent-decoding, upward segments, NUL and dotfiles have explicit handling; a Worker Fetch entry does not create filesystem capabilities.
(ns application.middleware
(:require [fast-twitch.middlewares.file :as middleware]))
(defn handler [_]
{:status 200 :headers {"content-type" "text/plain"} :body "Hello"})
(def app (middleware/wrap-file handler "static" {:url-root "static"}))
This defines the Ring handler portion. Adapt app through routing/ft-handler or pass it to server/listen!; startup instructions and a complete walkthrough show the surrounding project.
Settings and defaults
| Setting | Meaning |
|---|---|
:url-root |
URL prefix to strip; static maps /static/... to the given root |
:index-files? |
Default true when native metadata identifies a directory |
:show-dotfiles? |
Default false |
:headers |
Map or supported header-string sequence |
:prefer-handler? |
True delegates directly to the handler; no subsequent file retry |
Wrapper order and all middleware families. The function reference below preserves the upstream signatures and source links; helper functions do not all share the wrapper's arity.
Upstream function reference
Serves files from a local path with runtime-specific filesystem access and path safety checks.
file-request
(file-request request root-path)
(file-request request root-path options)
Function.
Attempts to serve a file for the request and returns nil when nothing matches. Source
wrap-file
(wrap-file handler root-path)
(wrap-file handler root-path options)
Function.
Wraps a handler with filesystem-backed static file serving. Source