stch.stateful.cookies documentation

Stateful cookie middleware.

*req-cookies*

*resp-cookies*

Cookies

Cookies type annotation.

Handler

Handler type annotation.

cookies

(cookies)
Inputs: []
Returns: Cookies

Returns all the request cookies.

get

(get k)(get k default)
Inputs: [k :- Named] [k :- Named, default :- Any]
Returns: Any

Returns the value of the cookie with name k
from the request.

put!

(put! k v)
Inputs: [k :- Named, v :- Any]
Returns: Cookies

Add a new cookie whose name is k and has the value v.
If v is a string a cookie map is created with :path '/'. To set
custom attributes, such as "expires", provide a map as v.
Stores all keys as strings.

remove!

(remove! k)(remove! k opts)
Inputs: [k :- Named] [k :- Named, opts :- {(optional-key :path) String, (optional-key :domain) String}]
Returns: Cookies

Remove the cookie with name k. Optionally pass
a map with the path and/or domain.

stateful-cookies

(stateful-cookies handler)
Inputs: [handler :- Handler]
Returns: Handler

update!

(update! k f & args)
Inputs: [k :- Named f :- (Fn) & args :- [Any]]
Returns: Cookies

Update the cookie with name k, calling f and any
additional args on it's value.

wrap-cookies-stateful

(wrap-cookies-stateful handler)
Inputs: [handler :- Handler]
Returns: Handler

A stateful layer inside wrap-cookies.