fast-twitch.middlewares.session
Complete generated reference for fast-twitch.middlewares.session
Usage and execution boundary
Loads session data from a cookie-backed key, not from the cookie payload itself. Saving requires response :session; an omitted field preserves the store, a map replaces saved contents, and nil deletes the session. The store is an atom-backed map in this implementation.
(ns application.middleware
(:require [fast-twitch.middlewares.session :as middleware]))
(defn handler [_]
{:status 200 :headers {"content-type" "text/plain"} :body "Hello"})
(def app (middleware/wrap-session handler {:cookie-name "example"}))
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 |
|---|---|
:store |
Default process-local default-store; memory-store creates another atom-backed store |
:cookie-name |
Default ft-session |
:root |
Default / |
:cookie-attrs |
Merged with path and HttpOnly defaults |
Response :session-cookie-attrs |
Per-response cookie attribute 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
Stores per-client session data in an atom-backed store and persists the key in a cookie.
default-store
delete-session
(delete-session store key)
Function.
Removes session data for the given key and returns nil for convenience. Source
memory-store
(memory-store)
Function.
Creates a fresh in-memory session store. Source
read-session
(read-session store key)
Function.
Reads session data for the given key from the store. Source
session-request
(session-request request)
(session-request request options)
Function.
Associates session metadata and session data onto the request map. Source
session-response
(session-response response request)
(session-response response request options)
Function.
Persists response session data and emits the corresponding session cookie. Source
wrap-session
(wrap-session handler)
(wrap-session handler options)
Function.
Wraps a handler with session loading and persistence. Source
write-session
(write-session store key data)
Function.
Writes session data and returns the existing or generated session key. Source