package current_web

  1. Overview
  2. Docs
type t

The context of a single web request.

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

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

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

val 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.

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

respond_redirect ctx uri redirects the user to uri.

val 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.