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.

respond_ok ctx content returns a successful page with content inserted into the site template.

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.