Module Static.Params

Params stores params of a request, either all or only required for authentication

type t
val params : Dream.request -> t option

params request returns t option if params were previously extracted for the request by set_params middleware.

type extractor = Dream.request -> t Lwt.t

extractor is a type of function which turns requests into params

val get_param : string -> t -> string option

get_param key params searches for a given key in params and returns Some str if it is present or None if it is not.

val get_param_exn : string -> t -> string

get_param_exn key params is the same as get_param, but returns an exeption if the key is not present

val get_param_req : string -> Dream.request -> string option

get_param_req key request is a shortcut for params request >>= get_param key.

val extract_query : extractor

extract_query request extracts all query params of a request and returns them as params

val extract_json : extractor

extract_json request extracts all pairs of keys and values of a JSON request. Content-Type must be application/json.

val extract_form : ?csrf:bool -> extractor

extract_form request extracts params from forms send with Dream.csrf_tag. Content-Type must be application/x-www-form-urlencoded.

val of_assoc : (string * string) list -> t

of_assoc lst creates t from assoc lists

val set_params : extractor:extractor -> Dream.handler -> Dream.request -> Dream.response Dream.promise

ser_params ~extractor is a middleware which sets params for a request, extracting them using ~extractor.