Module Webs_session.Handler

Session handlers.

type ('a, 'e) t

The type for session handler with state of type 'a and state loading errors of type 'e. Values of this type are in charge of loading the state when a request is received and saving it when a response is sent back and the state has changed.

val v : load:('a State.t -> Webs.Http.Request.t -> ('a option, 'e) Stdlib.result) -> save: ('a State.t -> 'a option -> Webs.Http.Response.t -> Webs.Http.Response.t) -> unit -> ('a, 'e) t

handler ~load ~save () is a session handler using load to setup the session state and save to save it before responding.

Sessions as are represented by 'a option values. On load a None indicates there is no session. On save a None indicates to drop the session.

Warning. save gets invoked iff the state to save is different from the one that was loaded.

val load : ('a, 'e) t -> 'a State.t -> Webs.Http.Request.t -> ('a option, 'e) Stdlib.result

load h is the state loading function of h.

val save : ('a, 'e) t -> 'a State.t -> 'a option -> Webs.Http.Response.t -> Webs.Http.Response.t

save h is the state saving function of h.