fast-twitch.middlewares.proxy-headers
Complete generated reference for fast-twitch.middlewares.proxy-headers
Usage and execution boundary
Rewrites scheme/host/port and real-ip/remote-addr from forwarded headers. wrap-real-ip updates only IP fields. Interpret these fields only after your deployment establishes which proxy headers are trusted.
(ns application.middleware
(:require [fast-twitch.middlewares.proxy-headers :as middleware]))
(defn handler [_]
{:status 200 :headers {"content-type" "text/plain"} :body "Hello"})
(def app (middleware/wrap-forwarded-headers 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 |
|---|---|
:real-ip-headers |
Ordered header list; default X-Forwarded-For, X-Real-IP, CF-Connecting-IP |
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
Adapts request connection details from forwarding and real-IP headers.
default-real-ip-headers
The default ordered headers used to derive the real client IP. Source
forwarded-for
(forwarded-for request)
Function.
Reads the first forwarded client address from request headers. Source
forwarded-host
(forwarded-host request)
Function.
Reads the first forwarded host value from request headers. Source
forwarded-proto
(forwarded-proto request)
Function.
Reads the first forwarded protocol value from request headers. Source
proxy-headers-request
(proxy-headers-request request)
(proxy-headers-request request options)
Function.
Associates forwarded scheme, host, port, and real IP fields onto the request map. Source
real-ip
(real-ip request)
(real-ip request options)
Function.
Returns the best client IP candidate from configured forwarding headers. Source
real-ip-request
(real-ip-request request)
(real-ip-request request options)
Function.
Associates only the derived real client IP without changing scheme or host. Source
split-host-port
(split-host-port host)
Function.
Splits a forwarded host value into :server-name and optional :server-port. Source
wrap-forwarded-headers
(wrap-forwarded-headers handler)
(wrap-forwarded-headers handler options)
Function.
Wraps a handler so forwarding headers update request connection fields. Source
wrap-real-ip
(wrap-real-ip handler)
(wrap-real-ip handler options)
Function.
Wraps a handler so real-IP headers update :real-ip and :remote-addr. Source