module Param:sig..end
Functions to process QUERY_STRING parameters. These functions handle mandatory vs. optional parameters, validation, and unexpected parameters.
type mandopt =
| |
Mandatory |
| |
Optional |
Types of QUERY_STRING parameters
typespec =string * mandopt * (string -> bool)
The type of parameter specifications.
Mandatory or Optionaltypespecs =spec list
The type of parameter specification lists.
type vparms
The type of validated parameter lists.
val process : ?strict:bool -> Netcgi.cgi -> specs -> vparmsprocess ?strict cgi spec: process QUERY_STRING parameters according to
spec, returning validated parameter list.
strict : if true, it is a 400 error to provide parameters not mentioned in spec (default: false)val value : ?default:string -> vparms -> string -> stringvalue ?default params name: given a validated parameter list
params, as returned by process, and a parameter name, return
the value of the parameter. If value is called for an
Optional parameter that was not provided, a 500 error will be
raised unless the ?default parameter was provided.
default : default value for an Optional parameterval optvalue : vparms -> string -> string optionoptvalue params name: given a validated parameter list params,
as returned by process, and a parameter name, return the value
of the parameter as a string option. Works for both Optional
and Mandatory parameters.
val get : Netcgi.cgi ->
mandopt -> (string -> bool) -> string -> string optionget cgi mandopt validator name: get one QUERY_STRING parameter
name, validating it with validator. If mandopt is Mandatory
and the parameter is not provided, a User_exn is raised. If
validator returns false, a User_exn is raised.
The return value is a string option; if mandopt is
Mandatory, a Some is guaranteed (else an error will have been
raised).
val at_least_one : string list -> vparms -> vparmsat_least_one names vp: insist that at least one of the parameters in names is given.
Use this when at least one of several parameters, which are all themselves optional, are required.
User_exn if none of the parameters are givenval mutex : ?atleast:bool ->
string list -> string list -> vparms -> vparmsmutex ?atleast x y vp: reject mutually exclusive parameters.
x and y are interpreted as two sets of mutually exclusive parameter names.
User_exn if mutually exclusive (or missing, required by ~atleast:true) parameters are foundatleast : if true, then at least one of the x's or y's must be given