---
name: "Eliom_parameter.server"
section: "3o"
platform: "linux"
package: "libeliom-ocaml-doc"
version: "4.0.0-2"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/Eliom_parameter.server"
---

# Eliom\_parameter.server(3o)

Ad-hoc runtime type representation for service parameters.

## NAME

Eliom\_parameter - Ad-hoc runtime type representation for service parameters.

## Module

Module   Eliom\_parameter

## Documentation

Module **Eliom\_parameter**\
  :  **sig end**

Ad-hoc runtime type representation for service parameters.

Please read Eliom's manual before this page to learn how to use .

*type* **('a, +'b, +'c)** *params\_type*

Abstract type for service parameters. See for example the parameter  **~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 **Eliom\_content.Html5.D.form\_widgets** of **Eliom\_content.HTML5.D** ). )

*type suff* =  **\[ \`Endsuffix \| \`WithSuffix \| \`WithoutSuffix \]**

This type is used as a phantom type in  **Eliom\_parameter.params\_type** to describe whether a parameter is encoded in the path of the URI as a suffix parameter.

**===** **Typed parameter's name** **===**

*type* **'a** *param\_name*

Abstract type for parameters' name. The  **'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*

Empty type used to denotes it is not possible to use the parameter in a form. See for example  **Eliom\_parameter.raw\_post\_data** .

*type* **'a** *setoneradio* =  **\[ \`One of 'a \| \`Radio of 'a \| \`Set of 'a \]**

A parameter arity could either be:

\- **\`Set of 'a** means: any number of  **'a** .

\- **\`One of 'a** means: exactly one  **'a** .

\- **\`Radio of 'a** means: zero or one  **'a** .

*type* **'a** *oneradio* =  **\[ \`One of 'a \| \`Radio of 'a \]**

Restriction of  **Eliom\_parameter.setoneradio** unary and optional parameters.

*type* **'a** *setone* =  **\[ \`One of 'a \| \`Set of 'a \]**

Restriction of  **Eliom\_parameter.setoneradio** unary and set parameters.

**===** **Types helpers** **===**

*type* **('a, 'b)** *binsum* =\
  \| Inj1 **of** **'a**\
  \| Inj2 **of** **'b**

Helpers type used for parameters of type binary sum, see  **Eliom\_parameter.sum** .

*type* **'an** *listnames* = {\
  it :  **'el 'a. ('an -\> 'el -\> 'a -\> 'a) -\> 'el list -\> 'a -\> 'a** ;\
  }

Helpers type used to construct forms from lists, see  **Eliom\_parameter.list** .

**===** **Basic types of pages parameters** **===**

*val int* :  **string -\>** **(int, \[ \`WithoutSuffix \], \[ \`One of int \] param\_name)** **params\_type**

Specifying parameter as  **int s** tells that the service takes an integer as parameter, labeled  **s** .

*val int32* :  **string -\>** **(int32, \[ \`WithoutSuffix \], \[ \`One of int32 \] param\_name)** **params\_type**

Specifying parameter as  **int32 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\_type**

Specifying parameter as  **int64 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\_type**

Specifying parameter as  **float 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\_type**

Specifying parameter as  **string s** tells that the service takes a string as parameter, labeled  **s** .

*val bool* :  **string -\>** **(bool, \[ \`WithoutSuffix \], \[ \`One of bool \] param\_name)** **params\_type**

Specifying parameter as  **bool 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\_type**

Specifying parameter as  **file s** tells that the service takes a file as parameter, labeled  **s** .

*val unit* :  **(unit, \[ \`WithoutSuffix \], unit) params\_type**

Specifying parameter as  **unit** is used for services that don't have any parameters

*val user\_type* :  **of\_string:(string -\> 'a) -\>** **to\_string:('a -\> string) -\>** **string -\>** **('a, \[ \`WithoutSuffix \], \[ \`One of 'a \] param\_name)** **params\_type**

Specifying parameter as  **user\_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, 'b, 'c) params\_type -\>** **('a, 'b, 'c) params\_type**

Specifying parameter as  **type\_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 :  **int** ;\
  ordinate :  **int** ;\
  }

The type  **coordinates** represent the data sent by an  **\<input** **type="image" ...\>** .

*val coordinates* :  **string -\>** **(coordinates, \[ \`WithoutSuffix \],** **\[ \`One of coordinates \] param\_name)** **params\_type**

Specifying parameter as  **coordinates 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\_type**

Specifying parameter as  **string\_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\_type**

Same as  **string\_coordinates** but for an integer value

*val int32\_coordinates* :  **string -\>** **(int32 \* coordinates, \[ \`WithoutSuffix \],** **\[ \`One of int32 \* coordinates \] param\_name)** **params\_type**

Same as  **string\_coordinates** but for a 32 bits integer value

*val int64\_coordinates* :  **string -\>** **(int64 \* coordinates, \[ \`WithoutSuffix \],** **\[ \`One of int64 \* coordinates \] param\_name)** **params\_type**

Same as  **string\_coordinates** but for a 64 integer value

*val float\_coordinates* :  **string -\>** **(float \* coordinates, \[ \`WithoutSuffix \],** **\[ \`One of float \* coordinates \] param\_name)** **params\_type**

Same as  **string\_coordinates** but for a float value

*val user\_type\_coordinates* :  **of\_string:(string -\> 'a) -\>** **to\_string:('a -\> string) -\>** **string -\>** **('a \* coordinates, \[ \`WithoutSuffix \],** **\[ \`One of 'a \* coordinates \] param\_name)** **params\_type**

Same as  **string\_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.

**===** **Composing types of pages parameters** **===**

*val ( \*\* )* :  **('a, \[ \`WithoutSuffix \], 'b) params\_type -\>** **('c, \[\< \`Endsuffix \| \`WithoutSuffix \] as 'e, 'd) params\_type -\>** **('a \* 'c, 'e, 'b \* 'd) params\_type**

The combinator  **p1 \*\* 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\_type**

Same as  **Eliom\_parameter.( \*\* )** .

*val sum* :  **('a, \[ \`WithoutSuffix \], 'b) params\_type -\>** **('c, \[ \`WithoutSuffix \], 'd) params\_type -\>** **(('a, 'c) binsum, \[ \`WithoutSuffix \], 'b \* 'd)** **params\_type**

The combinator  **sum 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\_type**

The combinator  **opt p** allow to define an optional parameter.

*val neopt* :  **('a, \[ \`WithoutSuffix \], 'b) params\_type -\>** **('a option, \[ \`WithoutSuffix \], 'b) params\_type**

The combinator  **neopt 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\_type**

Specifying parameter as  **radio 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\_type**

Use this if you want to take any parameters. The service will answer to all the request, and get all parameters as an association list of strings.

*val set* :  **(string -\>** **('a, \[ \`WithoutSuffix \], \[ \`One of 'b \] param\_name)** **params\_type) -\>** **string -\>** **('a list, \[ \`WithoutSuffix \], \[ \`Set of 'b \] param\_name)** **params\_type**

Use this if you want your service to take several parameters with the same name. The service handler will receive a list of values. To create the form, just use the same name several times. For example  **set 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\_type**

The service takes a list of parameters. The first parameter of this function is the name of the list. The service handler will receive a list of values. To create the form, an iterator of type  **Eliom\_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\_type**

**regexp 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 guard* :  **(string -\> ('a, 'b, 'c) params\_type) -\>** **string -\> ('a -\> bool) -\> ('a, 'b, 'c) params\_type**

**guard construct name pred** returns the same parameter as  **construct name** but with ensuring that each value must satisfy  **pred** . For instance:  **int age ((\>=) 0)**

*val suffix* :  **?redirect\_if\_not\_suffix:bool -\>** **('s, \[\< \`Endsuffix \| \`WithoutSuffix \], 'sn) params\_type -\>** **('s, \[ \`WithSuffix \], 'sn) params\_type**

Tells that the parameter of the service handler is the suffix of the URL of the current service. e.g.  **suffix (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\_type**

Takes all the suffix, as long as possible, as a (slash separated) string list

*val all\_suffix\_string* :  **string -\>** **(string, \[ \`Endsuffix \], \[ \`One of string \] param\_name)** **params\_type**

Takes all the suffix, as long as possible, as a string

*val all\_suffix\_user* :  **of\_string:(string -\> 'a) -\>** **to\_string:('a -\> string) -\>** **string -\>** **('a, \[ \`Endsuffix \], \[ \`One of 'a \] param\_name)** **params\_type**

Takes all the suffix, as long as possible, with a type specified by the user.

*val all\_suffix\_regexp* :  **Netstring\_pcre.regexp -\>** **string -\>** **to\_string:(string -\> string) -\>** **string -\>** **(string, \[ \`Endsuffix \], \[ \`One of string \] param\_name)** **params\_type**

**all\_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\_type**

Tells that the function that will generate the service takes a pair whose first element is the suffix of the URL of the current service, and the second element corresponds to other (regular) parameters. e.g.:  **suffix\_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\_type**

**suffix\_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*

marshaled OCaml values of type 'a

*val ocaml* :  **string -\>** **'a Deriving\_Json.t -\>** **('a, \[ \`WithoutSuffix \],** **\[ \`One of 'a ocaml \] param\_name)** **params\_type**

**ocaml 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.

*type raw\_post\_data* =  **((string \* string) \* (string \* string) list) option \*** **string Ocsigen\_stream.t option**

When the content type is neither URLencoded form data or multipart data, it is possible to get it as a stream of strings. The first element of the pair is the content-type. This kind of parameter cannot be combined with other ones, and it is not possible to create a form towards a service taking this kind of parameter.

*val raw\_post\_data* :  **(raw\_post\_data, \[ \`WithoutSuffix \],** **no\_param\_name)** **params\_type**

*type* **('a, +'tipo, +'names)** *non\_localized\_params*

**Non localized parameters**

*val make\_non\_localized\_parameters* :  **prefix:string -\>** **name:string -\>** **?persistent:bool -\>** **('a, \[ \`WithoutSuffix \], 'b) params\_type -\>** **('a, \[ \`WithoutSuffix \], 'b) non\_localized\_params**

create a new specification for non localized parameters. You must give a name to this set of parameters. Warning: the names must be unique for the whole application. That's why the name is composed by a prefix (the name of your project) and another string (the name of your non localized parameters).

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 option**

**get\_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 option**

**get\_non\_localized\_post\_parameters ~sp p** decodes and returns non localized POST parameters specified by  **p** if present.

*type nl\_params\_set*

Use this type to give non localized parameters to a link or a form

*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, 'b, 'c) params\_type -\> (string -\> 'a) \* ('a -\> string)**

Given a parameter type, get the two functions that converts from and to strings. You should only use this function on

\-options ;

\-basic types : int, int32, int64, float, string

\-marshal

\-unit

\-string

\-bool
