stch.stateful.session documentation
Stateful session middleware.
Handler
Handler type annotation.
assoc-in!
(assoc-in! ks v)
Inputs: [ks :- [Any], v :- Any]
Returns: Map
Associates a value in the session, where ks is a
sequence of keys and v is the new value and returns
a new nested structure. If any levels do not exist,
hash-maps will be created.
clear!
(clear!)
Inputs: []
Returns: Map
Remove all data from the session and start over cleanly.
destroy!
(destroy!)
Inputs: []
Returns: (Eq nil)
Destroy the session.
dissoc-in!
(dissoc-in! ks)
Inputs: [ks :- [Any]]
Returns: Map
Disassociates a value in the session, where ks is
a sequence of keys.
get
(get k)
(get k default)
Inputs: [k :- Any] [k :- Any, default :- Any]
Returns: Any
Get the key's value from the session, returns nil if it
doesn't exist.
get!
(get! k)
(get! k default)
Inputs: [k :- Any] [k :- Any, default :- Any]
Returns: Any
Destructive get from the session. Returns the
current value of the key and then removes it
from the session.
get-in
(get-in ks)
(get-in ks default)
Inputs: [ks :- [Any]] [ks :- [Any], default :- Any]
Returns: Any
Gets the value at the path specified by the vector ks
from the session, returns nil if it doesn't exist.
get-in!
(get-in! ks)
(get-in! ks default)
Inputs: [ks :- [Any]] [ks :- [Any], default :- Any]
Returns: Any
Destructive get from the session. This returns the
current value of the path specified by the vector
ks and then removes it from the session.
put!
(put! k v)
Inputs: [k :- Any, v :- Any]
Returns: Map
Associates the key with the given value in the session
remove!
(remove! k)
Inputs: [k :- Any]
Returns: Map
Remove a key from the session.
stateful-session
(stateful-session handler)
Inputs: [handler :- Handler]
Returns: Handler
Stateful session handler.
update!
(update! k f)
(update! k f & args)
Inputs: [k :- Any, f :- (Fn Any [Any])] [k :- Any f :- (Fn) & args :- [Any]]
Returns: Map
Update the value at key k, passing the current
value and args to f.
update-in!
(update-in! ks f)
(update-in! ks f & args)
Inputs: [ks :- [Any], f :- (Fn Any [Any])] [ks :- [Any] f :- (Fn) & args :- [Any]]
Returns: Map
Updates a value in the session, where ks is a
sequence of keys and f is a function that will
take the old value along with any supplied args and return
the new value. If any levels do not exist, hash-maps
will be created.
wrap-session-stateful
(wrap-session-stateful handler)
(wrap-session-stateful handler opts)
Inputs: [handler :- Handler] [handler :- Handler, opts :- Map]
Returns: Handler
A stateful layer inside wrap-session.
Options are passed to wrap-session.