module Eliom_parameter:sig..end
Please read Eliom's manual before this page to learn how to use .
~get_param of Eliom_service.Http.service.
'a is the type for the OCaml type of the
parameter as expected by the service handler. 'b is a phantom type, subtype of Eliom_parameter.suff, stating the kind
of the parameter: suffix or not. 'c is the type of the parameter name, usually an instance of
Eliom_parameter.param_name, as used by forms construction
functions (e. g. the last parameter of
Eliom_content.Html5.D.get_form), and specialized form widget (see
for example the section
Form widget of
Eliom_content.HTML5.D). )typesuff =[ `Endsuffix | `WithSuffix | `WithoutSuffix ]
Eliom_parameter.params_type to describe
whether a parameter is encoded in the path of the URI as a suffix
parameter.type ('a, +[< suff ], 'c) params_type
type +'a param_name
'a type parameter is a phantom type, usually a
subtype of Eliom_parameter.setoneradio, used to denotes the parameter's arity.type no_param_name
Eliom_parameter.raw_post_data.type'asetoneradio =[ `One of 'a | `Radio of 'a | `Set of 'a ]
`Set of 'a means: any number of 'a.`One of 'a means: exactly one 'a.`Radio of 'a means: zero or one 'a.type'aoneradio =[ `One of 'a | `Radio of 'a ]
Eliom_parameter.setoneradio unary and optional parameters.type'asetone =[ `One of 'a | `Set of 'a ]
Eliom_parameter.setoneradio unary and set parameters.type ('a, 'b) binsum =
| |
Inj1 of |
| |
Inj2 of |
Eliom_parameter.sum.type 'an listnames = {
|
it : |
Eliom_parameter.list.type 'a to_and_from = {
|
of_string : |
|
to_string : |
typeparams =(string * string) list
typefiles =(string * Eliom_lib.file_info) list
val int : string ->
(int, [ `WithoutSuffix ], [ `One of int ] param_name)
params_typeint s tells that the service takes an integer as parameter, labeled s.val int32 : string ->
(int32, [ `WithoutSuffix ], [ `One of int32 ] param_name)
params_typeint32 s tells that the service takes a 32 bits integer as parameter, labeled s.val int64 : string ->
(int64, [ `WithoutSuffix ], [ `One of int64 ] param_name)
params_typeint64 s tells that the service takes a 64 bits integer as parameter, labeled s.val float : string ->
(float, [ `WithoutSuffix ], [ `One of float ] param_name)
params_typefloat s tells that the service takes a floating point number as parameter, labeled s.val string : string ->
(string, [ `WithoutSuffix ], [ `One of string ] param_name)
params_typestring s tells that the service takes a string as parameter, labeled s.val bool : string ->
(bool, [ `WithoutSuffix ], [ `One of bool ] param_name)
params_typebool s tells that the service takes a boolean as parameter, labeled s.
(to use for example with boolean checkboxes)val file : string ->
(Eliom_lib.file_info, [ `WithoutSuffix ],
[ `One of Eliom_lib.file_info ] param_name)
params_typefile s tells that the service takes a file as parameter, labeled s.val unit : (unit, [ `WithoutSuffix ], unit) params_typeunit is used for services that don't have any parametersval user_type : of_string:(string -> 'a) ->
to_string:('a -> string) ->
string ->
('a, [ `WithoutSuffix ], [ `One of 'a ] param_name)
params_typeuser_type ~of_string ~to_string s tells that the
service take a parameter, labeled s, and that the server will
have to use of_string and to_string to make the conversion
between the OCaml representation of the parameter and it's
external representation as a string. It allows one to use whatever
type you want for a parameter of the service.val type_checker : ('a -> unit) ->
('a, [< suff ] as 'b, 'c) params_type ->
('a, 'b, 'c) params_typetype_checker check t
is equivalent as t but the check function is called after decoding the
parameters, allowing you to make more checks on the parameters before
the service handler is called. Raise an exception if the parameter
is not correct, and the error handler will be called instead of the
service handler.type coordinates = {
|
abscissa : |
|
ordinate : |
coordinates represent the data sent by an <input
type="image" ...>.val coordinates : string ->
(coordinates, [ `WithoutSuffix ],
[ `One of coordinates ] param_name)
params_typecoordinates s tells that the service takes as
parameters the coordinates of a point in an <input type="image"
...>.val string_coordinates : string ->
(string * coordinates, [ `WithoutSuffix ],
[ `One of string * coordinates ] param_name)
params_typestring_coordinates s tells that the service takes
as parameters the coordinates of a point and the associated
string value in an <input type="image" value="..." ...>.val int_coordinates : string ->
(int * coordinates, [ `WithoutSuffix ],
[ `One of int * coordinates ] param_name)
params_typestring_coordinates but for an integer valueval int32_coordinates : string ->
(int32 * coordinates, [ `WithoutSuffix ],
[ `One of int32 * coordinates ] param_name)
params_typestring_coordinates but for a 32 bits integer valueval int64_coordinates : string ->
(int64 * coordinates, [ `WithoutSuffix ],
[ `One of int64 * coordinates ] param_name)
params_typestring_coordinates but for a 64 integer valueval float_coordinates : string ->
(float * coordinates, [ `WithoutSuffix ],
[ `One of float * coordinates ] param_name)
params_typestring_coordinates but for a float valueval user_type_coordinates : of_string:(string -> 'a) ->
to_string:('a -> string) ->
string ->
('a * coordinates, [ `WithoutSuffix ],
[ `One of 'a * coordinates ] param_name)
params_typestring_coordinates but for a value of your own type. See
Eliom_parameter.user_type for a description of the of_string and to_string
parameters.val ( ** ) : ('a, [ `WithoutSuffix ], 'b) params_type ->
('c, [< `Endsuffix | `WithoutSuffix ] as 'e, 'd) params_type ->
('a * 'c, 'e, 'b * 'd) params_typep1 ** p2 allows one to define service that take a
pair of parameter. The associated service handler should expect a
pair (p1, p2) as parameter.val prod : ('a, [ `WithoutSuffix ], 'b) params_type ->
('c, [< `Endsuffix | `WithoutSuffix ] as 'e, 'd) params_type ->
('a * 'c, 'e, 'b * 'd) params_typeEliom_parameter.( ** ).val sum : ('a, [ `WithoutSuffix ], 'b) params_type ->
('c, [ `WithoutSuffix ], 'd) params_type ->
(('a, 'c) binsum, [ `WithoutSuffix ], 'b * 'd)
params_typesum p1 p2 allows one to define service that expect
either the parameter p1 or the parameter p2.val opt : ('a, [ `WithoutSuffix ], 'b) params_type ->
('a option, [ `WithoutSuffix ], 'b) params_typeopt p allow to define an optional parameter.val neopt : ('a, [ `WithoutSuffix ], 'b) params_type ->
('a option, [ `WithoutSuffix ], 'b) params_typeneopt p allow to define an optional parameter assumed to be None if empty.val radio : (string ->
('a, [ `WithoutSuffix ], [ `One of 'b ] param_name)
params_type) ->
string ->
('a option, [ `WithoutSuffix ], [ `Radio of 'b ] param_name)
params_typeradio f s tells that the service takes an optional
argument labeled s and of type f s. Use radio instead of
Eliom_parameter.opt if you want to use this parameter with a radio button.val any : ((string * string) list, [ `WithoutSuffix ], unit)
params_typeval set : (string ->
('a, [ `WithoutSuffix ], [ `One of 'b ] param_name)
params_type) ->
string ->
('a list, [ `WithoutSuffix ], [ `Set of 'b ] param_name)
params_typeset int "i" will match the parameter string
i=4&i=22&i=111 and send to the service handler a list containing
the three integers 4, 22 and 111. The order is unspecified.val list : string ->
('a, [ `WithoutSuffix ], 'b) params_type ->
('a list, [ `WithoutSuffix ], 'b listnames)
params_typeEliom_parameter.listnames is given to
generate the name for each value.val regexp : Netstring_pcre.regexp ->
string ->
to_string:(string -> string) ->
string ->
(string, [ `WithoutSuffix ], [ `One of string ] param_name)
params_typeregexp r d s tells that the service takes a string
that matches the regular expression r as parameter,
labeled s, and that will be rewritten in d.
The syntax of regexp is PCRE's one (uses Netstring_pcre, from OCamlnet).
For example: regexp (Netstring_pcre.regexp "\[(.* )\]") "($1)" "myparam"
will match the parameter myparam=[hello] and send the string "(hello)" to
the service handler.val suffix : ?redirect_if_not_suffix:bool ->
('s, [< `Endsuffix | `WithoutSuffix ], 'sn) params_type ->
('s, [ `WithSuffix ], 'sn) params_typesuffix (int "i" ** string "s") will match an URL ending by 380/yo.
and send (380, "yo") to the service handler.
For each service with suffix, there is also a service with regular
parameters (without suffix) that will be used if you create a form
towards a service with suffix.
If redirect_if_not_suffix is true (default),
this service without suffix will be redirected to the suffix version.
val all_suffix : string ->
(string list, [ `Endsuffix ],
[ `One of string list ] param_name)
params_typeval all_suffix_string : string ->
(string, [ `Endsuffix ], [ `One of string ] param_name)
params_typeval all_suffix_user : of_string:(string -> 'a) ->
to_string:('a -> string) ->
string ->
('a, [ `Endsuffix ], [ `One of 'a ] param_name)
params_typeval all_suffix_regexp : Netstring_pcre.regexp ->
string ->
to_string:(string -> string) ->
string ->
(string, [ `Endsuffix ], [ `One of string ] param_name)
params_typeall_suffix_regexp r d s takes all the suffix, as long as possible,
matching the regular expression r, name s, and rewrite it in d.val suffix_prod : ?redirect_if_not_suffix:bool ->
('s, [< `Endsuffix | `WithoutSuffix ], 'sn) params_type ->
('a, [ `WithoutSuffix ], 'an) params_type ->
('s * 'a, [ `WithSuffix ], 'sn * 'an) params_typesuffix_prod (int "suff" ** all_suffix "endsuff") (int "i")
will match an URL ending by 777/go/go/go?i=320 and send the value
((777, ["go";"go";"go"]), 320) to the service handler.val suffix_const : string ->
(unit, [ `WithoutSuffix ], [ `One of unit ] param_name)
params_typesuffix_const v is used only inside suffixes (do nothing for
regular parameters).
It tells that the service takes a constant parameter
inside the suffix, whose value must be v.
It is used for putting constant directory names inside
suffix parameters (and thus make suffix parameters not be only suffixes
but anywhere you want in the path, e.g. /param1/const/param2).type 'a ocaml
val ocaml : string ->
'a Deriving_Json.t ->
('a, [ `WithoutSuffix ],
[ `One of 'a ocaml ] param_name)
params_typeocaml s tells that the service is expecting some caml (client side)
program to send some value of type 'a, marshaled.
As usual s is the name of the parameter.typeraw_post_data =((string * string) * (string * string) list) option *
string Ocsigen_stream.t option
val raw_post_data : (raw_post_data, [ `WithoutSuffix ],
no_param_name)
params_type
type ('a, +[< suff ], 'names) non_localized_params
val make_non_localized_parameters : prefix:string ->
name:string ->
?persistent:bool ->
('a, [ `WithoutSuffix ], 'b) params_type ->
('a, [ `WithoutSuffix ], 'b) non_localized_params
Will fail with exception Failure _ if the name contains a dot.
If ?persistent is true, the non localized parameter
may remain if you call another service, if this service
allows this (default false).
val get_non_localized_get_parameters : ('a, [ `WithoutSuffix ], 'b) non_localized_params ->
'a optionget_non_localized_get_parameters ~sp p decodes and
returns non localized GET parameters specified by p if present.val get_non_localized_post_parameters : ('a, [ `WithoutSuffix ], 'b) non_localized_params ->
'a optionget_non_localized_post_parameters ~sp p decodes and
returns non localized POST parameters specified by p if present.type nl_params_set
val empty_nl_params_set : nl_params_set
val add_nl_parameter : nl_params_set ->
('a, [< `WithSuffix | `WithoutSuffix ], 'b)
non_localized_params -> 'a -> nl_params_set
val get_nl_params_names : ('b, [< `WithSuffix | `WithoutSuffix ], 'a)
non_localized_params -> 'a
val get_to_and_from : ('a, [< suff ], 'c) params_type ->
'a to_and_from