fast-twitch.middlewares.content-length
Complete generated reference for fast-twitch.middlewares.content-length
Usage and execution boundary
Adds byte lengths for supported bodies without consuming a native stream. Strings and sequential bodies use UTF-8 byte length; buffers, typed views and Blobs use their byte sizes. Do not equate character count with UTF-8 bytes.
(ns application.middleware
(:require [fast-twitch.middlewares.content-length :as middleware]))
(defn handler [_]
{:status 200 :headers {"content-type" "text/plain"} :body "Hello"})
(def app (middleware/wrap-content-length handler))
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.
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
Adds a Content-Length header when the response body size can be determined eagerly.
content-length-response
(content-length-response response _request)
Function.
Adds Content-Length to a response when it is missing and calculable. Source
wrap-content-length
(wrap-content-length handler)
Function.
Wraps a handler so its responses gain a Content-Length header when possible. Source