fast-twitch.middlewares.content-type
Complete generated reference for fast-twitch.middlewares.content-type
Usage and execution boundary
Infers Content-Type when absent, with extension mappings and native file/body information. The namespace also exposes file sniffing, compatibility warnings and upload summaries. Header declaration and format validation are distinct operations.
(ns application.middleware
(:require [fast-twitch.middlewares.content-type :as middleware]))
(defn handler [_]
{:status 200 :headers {"content-type" "text/plain"} :body "Hello"})
(def app (middleware/wrap-content-type 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.
Settings and defaults
| Setting | Meaning |
|---|---|
:mime-types |
Extension-based MIME overrides |
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
Infers content types from filenames, bytes, and file metadata for responses and uploads.
aifc-prefix
aiff-prefix
avi-prefix
base-content-type
(base-content-type s)
Function.
Strips parameters from a content type and lowercases the main media type. Source
bytes-at?
(bytes-at? bytes offset signature)
Function.
Returns true when the bytes at an offset match the given signature. Source
bytes-start-with?
(bytes-start-with? bytes signature)
Function.
Returns true when the byte sequence starts with the given signature. Source
compatible-content-type?
(compatible-content-type? expected sniffed)
Function.
Returns true when two content types should be treated as equivalent. Source
content-type
content-type-aliases
content-type-response
(content-type-response response request)
(content-type-response response request options)
Function.
Adds a Content-Type header to responses that do not already specify one. Source
content-type-warning
(content-type-warning declared expected sniffed)
Function.
Explains the first mismatch found between declared, expected, and sniffed types. Source
ebml-prefix
eot-prefix
expected-content-type
(expected-content-type filename)
Function.
Looks up the extension-derived content type for a filename. Source
file-bytes
(file-bytes file)
Function.
Reads the leading bytes used for file content sniffing. Source
file-content-type-summary
(file-content-type-summary file)
Function.
Builds an upload summary with declared, expected, sniffed, and warning fields. Source
filename-extension
(filename-extension filename)
Function.
Returns the extension portion of a filename, including the leading dot. Source
form-prefix
ftyp-prefix
html-tag-prefixes
mp4-brand-prefix
prefix-content-types
resource-header-size
riff-prefix
sniff-content-type
(sniff-content-type bytes)
Function.
Infers a content type from leading bytes using signature and text heuristics. Source
starts-with
svg-tag-prefix
tar-prefix
wave-prefix
webm-doctype
webp-chunk-prefix
webp-prefix
wrap-content-type
(wrap-content-type handler)
(wrap-content-type handler options)
Function.
Wraps a handler so missing Content-Type headers are inferred automatically. Source