package current_web

  1. Overview
  2. Docs

Module Current_web.ContextSource

Sourcetype t

The context of a single web request.

Sourceval of_request : site:Site.t -> Cohttp.Request.t -> t Lwt.t
Sourceval request : t -> Cohttp.Request.t
Sourceval csrf : t -> string

csrf t is the user's CSRF token to include in POST forms.

Sourceval set_user : t -> User.t -> (Cohttp.Response.t * Cohttp_lwt.Body.t) Lwt.t

set_user t user records a successful login by user and redirects the user back to the page they came from.

Sourceval respond_ok : t -> ?refresh:int -> [< Html_types.div_content_fun ] Tyxml.Html.elt list -> (Cohttp.Response.t * Cohttp_lwt.Body.t) Lwt.t

respond_ok ctx refresh content returns a successful page with content inserted into the site template. If refresh is Some s, the page is refreshed every s seconds.

Sourceval respond_redirect : t -> Uri.t -> (Cohttp.Response.t * Cohttp_lwt.Body.t) Lwt.t

respond_redirect ctx uri redirects the user to uri.

Sourceval respond_error : t -> Cohttp.Code.status_code -> string -> (Cohttp.Response.t * Cohttp_lwt.Body.t) Lwt.t

respond_error ctx code msg returns an error message to the user, inside the site template.

OCaml

Innovation. Community. Security.