session/mw
src/session/mw.tur
the session middleware constructor and response flush.
Since: v0.1.0
defn
session-flush
(session-flush [ctx : Ctx resp : Response] :)
the after-middleware: persist + free per-request state.
defn
session-mw
(session-mw [store : Store cfg : SessionConfig] :)
install a store + cookie config and return the middleware.
Parameters
| store | a Store (memory-store-new, file-store-new, valkey-store-new, or | |
| a custom store-new) | ||
| cfg | a SessionConfig (default-session-config / dev-session-config) |
Returns
:int -- a tourist item handle.
Example
(tourist 3000
(session-mw (memory-store-new) (dev-session-config))
(get! "/" (fn [ctx] (text (session-id ctx)))))
Since: v0.1.0
Internal definitions
__cstr-null?__should-persist?-- whether a non-destroyed session needs saving.__flush-persist-- store-save/delete + Set-Cookie for one request.__flush-rotate-delete-- delete the pre-rotate store entry, if any.