module Args: sig .. end
Arguments
exception Missing_argument of (string * string)
argument, message
exception Missing_cookie of (string * string)
argument, message
exception Read_errors of exn list
Exception raised by the read function generated by the cgi_template tool.
Simple interface
type spec =
| |
Unit of (unit -> unit) |
| |
Set of bool Pervasives.ref |
| |
Clear of bool Pervasives.ref |
| |
String of (string -> unit) |
| |
Int of (int -> unit) |
| |
Float of (float -> unit) |
| |
Mail_address of (string -> unit) |
| |
Regexp of Str.regexp * (string -> unit) |
| |
Set_string of string Pervasives.ref |
| |
Set_int of int Pervasives.ref |
| |
Set_float of float Pervasives.ref |
| |
Set_mail_address of string Pervasives.ref |
| |
Set_regexp of Str.regexp * string Pervasives.ref |
Set, Clear and Unit will be called when the given argument name is associated
to a non-empty string in the cgi arguments
type spec_option =
val parse : Env.cgi_env -> (string * spec * spec_option list) list -> unit
Example of an element of the list:
"id", Int (fun n -> id := n), [Mandatory "The id parameter is missing!"]
Low-level and more powerful interface
val raw_mandatory : Env.cgi_env -> err:string -> string -> Env.argument_value
raw_mandatory env ~err: error_message arg_name returns the
Env.argument_value associated to the given
arg_name in the CGI environment
env.
Raises Missing_argument if the argument has no value in the given environment.
val raw_optional : Env.cgi_env -> string -> Env.argument_value option
raw_optional env arg_name returns the optional
Env.argument_value
of
arg_name in the given environment.
val mandatory : Env.cgi_env -> err:string -> string -> string
mandatory env ~err: error_message arg_name returns the value associated
to the given arg_name in the CGI environment env.
Raises Missing_argument if the argument has no value in the given environment.
val optional_f : Env.cgi_env -> (string -> 'a) -> string -> 'a option
optional_f env f arg_name returns the optional application of f to
the value of arg_name in the given environment.
val optional : Env.cgi_env -> string -> string option
optional env arg_name returns the optional value of arg_name in the
given environment.
val mandatory_cookie : Env.cgi_env -> err:string -> string -> string
mandatory_cookie env ~err: error_message arg_name returns the value associated
to the given arg_name in the cookies of the CGI environment env.
Raises Missing_cookie if the argument has no value in the given environment.
val optional_f_cookie : Env.cgi_env -> (string -> 'a) -> string -> 'a option
optional_f_cokie env f arg_name returns the optional application of f to
the value of arg_name in the cookies of the given environment.
val optional_cookie : Env.cgi_env -> string -> string option
optional_cookie env arg_name returns the optional value of arg_name in the
cookies of the given environment.
val int_arg : Env.cgi_env -> ?default:int -> ?err:string -> string -> int
int_arg env ~err: "message" arg_name
RaisesFailure if the argument value is not an int
Missing_argument if the argument has no value and no default vale is specified.
val float_arg : Env.cgi_env -> ?default:float -> ?err:string -> string -> float
val mail_arg : Env.cgi_env -> ?default:string -> ?err:string -> string -> string
Same as
Args.int_arg but for email addresses. Check that the value of the argument
in the environment is a valid email address.
val string_arg : Env.cgi_env -> ?default:string -> ?err:string -> string -> string
val arg : Env.cgi_env -> (string -> 'a) -> ?default:'a -> ?err:string -> string -> 'a
Same as
Args.int_arg but the conversion function is a parameter.
Other functions used to retrieve arg values
and perform some tests
val check_mail : string -> string
Check that the given mail string is a valid email
address (has '@' and something on each side).
Raises Failure if it is not the case
Returns the given string is everything is ok