API reference

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

Source

aiff-prefix

Source

avi-prefix

Source

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

Source

content-type-aliases

Source

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

Source

eot-prefix

Source

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

Source

ftyp-prefix

Source

html-tag-prefixes

Source

mp4-brand-prefix

Source

prefix-content-types

Source

resource-header-size

Source

riff-prefix

Source

sniff-content-type

(sniff-content-type bytes)

Function.

Infers a content type from leading bytes using signature and text heuristics. Source

starts-with

Source

svg-tag-prefix

Source

tar-prefix

Source

wave-prefix

Source

webm-doctype

Source

webp-chunk-prefix

Source

webp-prefix

Source

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

xml-prefix

Source


Source revision a4eb73f96836d034c7a24fe09dc7d51e4c581f64

Built with Fast-Twitch · Integrant · Datastar

Search documentation

Search pages and API symbols

Start hereWelcome to Fast-TwitchRing HTTP applications and configured native clients and transports in ClojureScript.Start hereGetting startedCompile and run your first Fast-Twitch server.Core conceptsRequest & responseUnderstand the maps at the center of a Fast-Twitch application.Core conceptsRoutingMatch URL patterns and compose handlers.Core conceptsMiddlewareWrap handlers with focused request and response behavior.GuidesHTML & IntegrantCompose a UI system with Integrant and render Hiccup.