---
name: "Eliom_service.Http.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_service.Http.server"
---

# Eliom\_service.Http.server(3o)

Default module for creating services

## NAME

Eliom\_service.Http - Default module for creating services

## Module

Module   Eliom\_service.Http

## Documentation

Module **Http**\
  :  **sig end**

Default module for creating services

**===** **Definitions of services** **Warning: These functions must be called when the site** **information is available, that is, either during a request or** **during the initialisation phase of the site. Otherwise, it will** **raise the exception** **Eliom\_common.Eliom\_site\_information\_not\_available. If you are** **using static linking, you must delay the call to this function** **until the configuration file is read, using** **Eliom\_service.register\_eliom\_module. Otherwise you will also** **get this exception. ===**

**===** **Main services** **===**

*val service* :  **?rt:'rt Eliom\_service.rt -\>** **?https:bool -\>** **path:Eliom\_lib.Url.path -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **?priority:int -\>** **get\_params:('get, \[\< Eliom\_service.suff \] as 'a, 'gn)** **Eliom\_parameter.params\_type -\>** **unit -\>** **('get, unit,** **\[\> \`Attached of** **(\[\> \`Internal of \[\> \`Service \] \], \[\> \`Get \]) Eliom\_service.a\_s \],** **'a, 'gn, unit, \[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **service ~path ~get\_params ()** creates a  **Eliom\_service.Http.service** associated to the path  **path** and taking  **get\_params** as GET parameters.

If the optional parameter  **~https:true** is given, all links towards that service will use https. By default, links will keep the current protocol.

The optional parameter  **~priority** allows one to change the priority order between service that shares the same path. The default priority is 0 ; if you want the service to be tried before (resp. after) other services, put a higher (resp. lower) priority.

If the optional parameter  **~keep\_nl\_params:\`Persistent** (resp.  **~keep\_nl\_params:\`All** ) is given, all links towards that service will keep persistent (resp. all) non localized GET parameters of the current service. The default is  **\`None** . See the eliom manual for more information about .

The optional parameter  **?rt** is used to constrain the type parameter  **'rt** of the service in the case it is  **'rt Eliom\_service.ocaml\_service** . Example: **service ~rt:(Eliom\_service.rt : your\_return\_type Eliom\_service.rt)** .

*val post\_service* :  **?rt:'rt Eliom\_service.rt -\>** **?https:bool -\>** **fallback:('get, unit,** **\[ \`Attached of** **(\[ \`Internal of \[ \`Coservice \| \`Service \] \], \[ \`Get \])** **Eliom\_service.a\_s \],** **\[\< Eliom\_service.suff \] as 'a, 'gn, unit, \[\< \`Registrable \],** **\[\< Eliom\_service.non\_ocaml\_service \])** **Eliom\_service.service -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **?priority:int -\>** **post\_params:('post, \[ \`WithoutSuffix \], 'pn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, 'post,** **\[\> \`Attached of** **(\[\> \`Internal of \[ \`Coservice \| \`Service \] \], \[\> \`Post \])** **Eliom\_service.a\_s \],** **'a, 'gn, 'pn, \[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **post\_service ~fallback ~post\_params ()** creates a service that takes  **post\_params** as POST parameters and share the same path and GET parameters than the service  **fallback** .

POST parameters couldn't contain a suffix parameter.

The service  **fallback** should be an (internal) attached service without POST parameters ; it couldn't be a preapplied service. This argument enforces the creation of an equivalent service ( i.e. a service with the same path and GET parameters ) to be served when POST parameters are missing. Thus, the user cannot put a bookmark on a page that does not exist.

See  **Eliom\_service.Http.service** for a description of optional  **~https** , **~keep\_nl\_params** ,  **~priority** and  **~rt** parameters .

*val put\_service* :  **?rt:'rt Eliom\_service.rt -\>** **?https:bool -\>** **path:Eliom\_lib.Url.path -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **?priority:int -\>** **get\_params:('get, \[\< Eliom\_service.suff \] as 'a, 'gn)** **Eliom\_parameter.params\_type -\>** **unit -\>** **('get, Eliom\_parameter.raw\_post\_data,** **\[\> \`Attached of** **(\[\> \`Internal of \[\> \`Service \] \], \[\> \`Put \]) Eliom\_service.a\_s \],** **'a, 'gn, Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **put\_service ~path ~get\_params ()** creates a service that answers the HTTP PUT method, and only takes **Eliom\_parameter.raw\_post\_data** as POST parameter.

**path** and  **get\_params** , however, can be set at will.

See  **Eliom\_service.Http.service** for a description of optional  **~https** , **~keep\_nl\_params** ,  **~priority** and  **~rt** parameters .

*val delete\_service* :  **?rt:'rt Eliom\_service.rt -\>** **?https:bool -\>** **path:Eliom\_lib.Url.path -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **?priority:int -\>** **get\_params:('get, \[\< Eliom\_service.suff \] as 'a, 'gn)** **Eliom\_parameter.params\_type -\>** **unit -\>** **('get, Eliom\_parameter.raw\_post\_data,** **\[\> \`Attached of** **(\[\> \`Internal of \[\> \`Service \] \], \[\> \`Delete \]) Eliom\_service.a\_s \],** **'a, 'gn, Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **delete\_service ~path ~get\_params ()** creates a service that answers the HTTP DELETE method, and only takes **Eliom\_parameter.raw\_post\_data** as POST parameter.

**path** and  **get\_params** , however, can be set at will.

See  **Eliom\_service.Http.service** for a description of optional  **~https** , **~keep\_nl\_params** ,  **~priority** and  **~rt** parameters .

**===** **Attached coservices** **===**

*val coservice* :  **?rt:'rt Eliom\_service.rt -\>** **?name:string -\>** **?csrf\_safe:bool -\>** **?csrf\_scope:\[\< Eliom\_common.user\_scope \] -\>** **?csrf\_secure:bool -\>** **?max\_use:int -\>** **?timeout:float -\>** **?https:bool -\>** **fallback:(unit, unit,** **\[ \`Attached of** **(\[ \`Internal of \[ \`Service \] \], \[ \`Get \]) Eliom\_service.a\_s \],** **\[ \`WithoutSuffix \], unit, unit, \[\< Eliom\_service.registrable \],** **\[\< Eliom\_service.non\_ocaml\_service \])** **Eliom\_service.service -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[ \`WithoutSuffix \], 'gn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, unit,** **\[\> \`Attached of** **(\[\> \`Internal of \[\> \`Coservice \] \], \[\> \`Get \]) Eliom\_service.a\_s \],** **\[ \`WithoutSuffix \], 'gn, unit,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **coservice ~fallback ~get\_params** creates an  at the same path than the service  **fallback** and taking  **get\_params** as GET parameters.

GET parameters of  **coservice** couldn't contain a suffix parameter.

The service  **fallback** should be an (internal) attached service without any GET or POST parameters ; it could be a preapplied service.

The optional  **~name** parameter Coservices can be named if the  **?name** optional parameter is present or anonymous (in that case, a coservice number will be generated).

The optional  **~timeout** parameter specifies a timeout (in seconds) after which the coservice will disappear. This amount of time is computed from the creation or from the last call to the service. The default is "no timeout". The optional  **~max\_use** parameter specifies that the service can be used only a fixed number of times. The default is "no limitation".

If the optional  **~csrf\_safe** parameter is  **true** , it will create a . In that case the  **~name** parameter is ignored. The default is  **false** .

The  **~csrf\_scope** and  **~csrf\_secure** , if present, should respectively correspond to the  **~scope** and  **~secure** parameters that will be given to the associated  **register** function. Otherwise the registration will fail with . See **Eliom\_registration.Html5.register** , **Eliom\_registration.App.register** or any other **Eliom\_registration** **.\*.register** functions for a description of those parameters.

See  **Eliom\_service.Http.service** for a description of the optional  **~https** ,  **~rt** and **~keep\_nl\_params** parameters .

*val post\_coservice* :  **?rt:'rt Eliom\_service.rt -\>** **?name:string -\>** **?csrf\_safe:bool -\>** **?csrf\_scope:\[\< Eliom\_common.user\_scope \] -\>** **?csrf\_secure:bool -\>** **?max\_use:int -\>** **?timeout:float -\>** **?https:bool -\>** **fallback:('get, unit,** **\[ \`Attached of** **(\[ \`Internal of \[\< \`Coservice \| \`Service \] \], \[ \`Get \])** **Eliom\_service.a\_s \],** **\[\< Eliom\_service.suff \] as 'a, 'gn, unit, \[\< \`Registrable \],** **\[\< Eliom\_service.non\_ocaml\_service \])** **Eliom\_service.service -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **post\_params:('post, \[ \`WithoutSuffix \], 'pn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, 'post,** **\[\> \`Attached of** **(\[\> \`Internal of \[\> \`Coservice \] \], \[\> \`Post \]) Eliom\_service.a\_s \],** **'a, 'gn, 'pn, \[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **post\_coservice ~fallback ~post\_params** creates an  with the same path and GET parameters than the service  **fallback** and taking  **post\_params** as POST parameters.

POST parameters couldn't contain a suffix parameter.

The service  **fallback** should be an (internal) attached service or coservice without any POST parameters ; it could be a preapplied service.

See  **Eliom\_service.Http.coservice** for a description of optional parameters.

*val put\_coservice* :  **?rt:'rt Eliom\_service.rt -\>** **?name:string -\>** **?csrf\_safe:bool -\>** **?csrf\_scope:\[\< Eliom\_common.user\_scope \] -\>** **?csrf\_secure:bool -\>** **?max\_use:int -\>** **?timeout:float -\>** **?https:bool -\>** **fallback:(unit, Eliom\_parameter.raw\_post\_data,** **\[ \`Attached of** **(\[ \`Internal of \[ \`Service \] \], \[ \`Put \]) Eliom\_service.a\_s \],** **\[ \`WithoutSuffix \], unit, Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \],** **\[\< Eliom\_service.non\_ocaml\_service \])** **Eliom\_service.service -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[ \`WithoutSuffix \], 'gn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, Eliom\_parameter.raw\_post\_data,** **\[\> \`Attached of** **(\[\> \`Internal of \[\> \`Coservice \] \], \[\> \`Put \]) Eliom\_service.a\_s \],** **\[ \`WithoutSuffix \], 'gn, Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **put\_coservice ~fallback ~get\_params** creates an  with the same path and GET parameters than the service  **fallback** and taking a single POST parameter of type **Eliom\_parameter.raw\_post\_data** .

The service  **fallback** should be an (internal) attached PUT service or coservice without any GET parameters ; it could be a preapplied service.

See  **Eliom\_service.Http.coservice** for a description of optional parameters.

*val delete\_coservice* :  **?rt:'rt Eliom\_service.rt -\>** **?name:string -\>** **?csrf\_safe:bool -\>** **?csrf\_scope:\[\< Eliom\_common.user\_scope \] -\>** **?csrf\_secure:bool -\>** **?max\_use:int -\>** **?timeout:float -\>** **?https:bool -\>** **fallback:(unit, Eliom\_parameter.raw\_post\_data,** **\[ \`Attached of** **(\[ \`Internal of \[ \`Service \] \], \[ \`Delete \]) Eliom\_service.a\_s \],** **\[ \`WithoutSuffix \], unit, Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \],** **\[\< Eliom\_service.non\_ocaml\_service \])** **Eliom\_service.service -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[ \`WithoutSuffix \], 'gn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, Eliom\_parameter.raw\_post\_data,** **\[\> \`Attached of** **(\[\> \`Internal of \[\> \`Coservice \] \], \[\> \`Delete \]) Eliom\_service.a\_s \],** **\[ \`WithoutSuffix \], 'gn, Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **delete\_coservice ~fallback ~get\_params** creates an  with the same path and GET parameters than the service  **fallback** and taking a single POST parameter of type **Eliom\_parameter.raw\_post\_data** .

The service  **fallback** should be an (internal) attached DELETE service or coservice without any GET parameters ; it could be a preapplied service.

See  **Eliom\_service.Http.coservice** for a description of optional parameters.

**===** **Non attached coservices** **===**

*val coservice'* :  **?rt:'rt Eliom\_service.rt -\>** **?name:string -\>** **?csrf\_safe:bool -\>** **?csrf\_scope:\[\< Eliom\_common.user\_scope \] -\>** **?csrf\_secure:bool -\>** **?max\_use:int -\>** **?timeout:float -\>** **?https:bool -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[ \`WithoutSuffix \], 'gn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, unit, \[\> \`Nonattached of \[\> \`Get \] Eliom\_service.na\_s \],** **\[ \`WithoutSuffix \], 'gn, unit,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **coservice' ~get\_param** creates a  taking  **get\_params** as extra GET parameters.

GET parameters of  **coservice'** couldn't contain a suffix parameter.

See  **Eliom\_service.Http.service** for a description of the optional  **~https** ,  **~rt** and **~keep\_nl\_params** parameters ; see  **Eliom\_service.Http.coservice** for others optional parameters.

*val post\_coservice'* :  **?rt:'rt Eliom\_service.rt -\>** **?name:string -\>** **?csrf\_safe:bool -\>** **?csrf\_scope:\[\< Eliom\_common.user\_scope \] -\>** **?csrf\_secure:bool -\>** **?max\_use:int -\>** **?timeout:float -\>** **?https:bool -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **?keep\_get\_na\_params:bool -\>** **post\_params:('post, \[ \`WithoutSuffix \], 'pn) Eliom\_parameter.params\_type -\>** **unit -\>** **(unit, 'post, \[\> \`Nonattached of \[\> \`Post \] Eliom\_service.na\_s \],** **\[ \`WithoutSuffix \], unit, 'pn,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **post\_coservice' ~post\_params** creates a  taking  **post\_params** as POST parameters.

POST parameters couldn't contain a suffix parameter.

If the optional parameter  **~keep\_get\_na\_params** is  **false** , GET non-attached parameters of the current page won't be kept in the URL (if any) when you create a POST form to this coservice. The default is true.

See  **Eliom\_service.Http.service** for a description of the optional  **~https** ,  **~rt** and **~keep\_nl\_params** parameters ; see  **Eliom\_service.Http.coservice** for others optional parameters.

*val put\_coservice'* :  **?rt:'rt Eliom\_service.rt -\>** **?name:string -\>** **?csrf\_safe:bool -\>** **?csrf\_scope:\[\< Eliom\_common.user\_scope \] -\>** **?csrf\_secure:bool -\>** **?max\_use:int -\>** **?timeout:float -\>** **?https:bool -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[ \`WithoutSuffix \], 'gn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, Eliom\_parameter.raw\_post\_data,** **\[\> \`Nonattached of \[\> \`Put \] Eliom\_service.na\_s \], \[ \`WithoutSuffix \], 'gn,** **Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **put\_coservice' ~get\_params** creates a  taking a single POST parameter of type **Eliom\_parameter.raw\_post\_data** .

See  **Eliom\_service.Http.service** for a description of the optional  **~https** ,  **~rt** and **~keep\_nl\_params** parameters ; see  **Eliom\_service.Http.coservice** for others optional parameters.

*val delete\_coservice'* :  **?rt:'rt Eliom\_service.rt -\>** **?name:string -\>** **?csrf\_safe:bool -\>** **?csrf\_scope:\[\< Eliom\_common.user\_scope \] -\>** **?csrf\_secure:bool -\>** **?max\_use:int -\>** **?timeout:float -\>** **?https:bool -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[ \`WithoutSuffix \], 'gn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, Eliom\_parameter.raw\_post\_data,** **\[\> \`Nonattached of \[\> \`Delete \] Eliom\_service.na\_s \], \[ \`WithoutSuffix \],** **'gn, Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \> \`Registrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **delete\_coservice' ~get\_params** creates a  taking a single POST parameter of type **Eliom\_parameter.raw\_post\_data** .

See  **Eliom\_service.Http.service** for a description of the optional  **~https** ,  **~rt** and **~keep\_nl\_params** parameters ; see  **Eliom\_service.Http.coservice** for others optional parameters.

*val external\_service* :  **prefix:string -\>** **path:Eliom\_lib.Url.path -\>** **?rt:'rt Eliom\_service.rt -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[\< Eliom\_service.suff \] as 'a, 'gn)** **Eliom\_parameter.params\_type -\>** **unit -\>** **('get, unit, \[\> \`Attached of (\[\> \`External \], \[\> \`Get \]) Eliom\_service.a\_s \],** **'a, 'gn, unit, \[\< Eliom\_service.registrable \> \`Unregistrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

The function  **external\_service ~prefix ~path ~get\_params ()** creates a service for an external web site, that will use GET method and requires  **get\_params** as parameters. This allows one to creates links or forms towards other Web sites using Eliom's syntax.

The parameter labelled  **~path** is the URL path. Each element of the list will be URL-encoded.

The parameter labelled  **~prefix** contains all what you want to put before the path. It usually starts with "http://" plus the name of the server. The prefix is not URL encoded.

The whole URL is constructed from the prefix, the path and GET parameters. Hence, an empty prefix can be used to make a link to another site of the same server.

See  **Eliom\_service.Http.service** for a description of the optional **~keep\_nl\_params** and  **~rt** parameters.

*val external\_post\_service* :  **prefix:string -\>** **path:Eliom\_lib.Url.path -\>** **?rt:'rt Eliom\_service.rt -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[\< Eliom\_service.suff \] as 'a, 'gn)** **Eliom\_parameter.params\_type -\>** **post\_params:('post, \[ \`WithoutSuffix \], 'pn) Eliom\_parameter.params\_type -\>** **unit -\>** **('get, 'post,** **\[\> \`Attached of (\[\> \`External \], \[\> \`Post \]) Eliom\_service.a\_s \], 'a, 'gn,** **'pn, \[\< Eliom\_service.registrable \> \`Unregistrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

Same as  **Eliom\_service.Http.external\_service** but with POST method.

*val external\_put\_service* :  **prefix:string -\>** **path:Eliom\_lib.Url.path -\>** **?rt:'rt Eliom\_service.rt -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[\< Eliom\_service.suff \] as 'a, 'gn)** **Eliom\_parameter.params\_type -\>** **unit -\>** **('get, Eliom\_parameter.raw\_post\_data,** **\[\> \`Attached of (\[\> \`External \], \[\> \`Put \]) Eliom\_service.a\_s \], 'a, 'gn,** **Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \> \`Unregistrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

Same as  **Eliom\_service.Http.external\_service** but with PUT method.

*val external\_delete\_service* :  **prefix:string -\>** **path:Eliom\_lib.Url.path -\>** **?rt:'rt Eliom\_service.rt -\>** **?keep\_nl\_params:\[ \`All \| \`None \| \`Persistent \] -\>** **get\_params:('get, \[\< Eliom\_service.suff \] as 'a, 'gn)** **Eliom\_parameter.params\_type -\>** **unit -\>** **('get, Eliom\_parameter.raw\_post\_data,** **\[\> \`Attached of (\[\> \`External \], \[\> \`Delete \]) Eliom\_service.a\_s \], 'a, 'gn,** **Eliom\_parameter.no\_param\_name,** **\[\< Eliom\_service.registrable \> \`Unregistrable \],** **\[\> Eliom\_service.http\_service \])** **Eliom\_service.service**

Same as  **Eliom\_service.Http.external\_service** but with DELETE method.
