---
name: "Eliom_registration.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_registration.server"
---

# Eliom\_registration.server(3o)

Eliom services registration for various kinds of page content: Eliom application, valid Eliom\_registration.Html5, actions, redirections, static files, …

## NAME

Eliom\_registration - Eliom services registration for various kinds of page content: Eliom application, valid Eliom\_registration.Html5, actions, redirections, static files, …

## Module

Module   Eliom\_registration

## Documentation

Module **Eliom\_registration**\
  :  **sig end**

Eliom services registration for various kinds of page content: Eliom application, valid  **Eliom\_registration.Html5** , actions, redirections, static files, …

**=== Please read the Eliom manual before this page to learn how to use** **{% \<\<a\_manual chapter="server-services" \| services** **\>\> %} and {% \<\<a\_manual chapter="server-outputs" \| predefined outputs** **\>\> %}. ===**

**=== {% \<\<outline\| \<\<header\| \*\*Table of contents\*\* \>\> \>\> %} ===**

**===** **Type definitions** **===**

*type* **'a** *kind*

The type  **kind** is an abstract type for the HTTP frame returned by a service. The type parameters are phantom types describing the content of the frame:

\-The second parameter is the same as the last type parameters of the corresponding  **Eliom\_service.service** . Currently, one of the following types:

\- **Eliom\_service.appl\_service**

\- **Eliom\_service.http\_service**

\- **Eliom\_service.ocaml\_service**

\-The first parameter is a refinement of the second parameter. Currently, one of the following types:

\- **Eliom\_registration.application\_content**

\- **Eliom\_registration.browser\_content**

\- **Eliom\_registration.block\_content**

\- **Eliom\_registration.unknown\_content**

\- **Eliom\_registration.ocaml\_content**

**===** **Return types for Eliom\_service.service** **===**

**===** **Classical content** **===**

*type http\_service* =  **Eliom\_service.http\_service**

The type  **http\_service** is used as a phantom type parameters for **Eliom\_service.service** and  **Eliom\_registration.kind** . It means the returned content is classical HTTP content described by the content type header. See  **Eliom\_registration.kind** for a list of others return types.

*type browser\_content* =  **\[ \`Browser \]**

The type  **browser\_content** is a refinement of  **Eliom\_registration.http\_service** to be used as a phantom type parameters for  **Eliom\_registration.kind** . It means the returned content must be interpreted in the browser as stated by the content-type header. This is most common return type for an eliom service, see for example  **Eliom\_registration.Html5** , **Eliom\_registration.CssText** ,  **Eliom\_registration.File** ,  **Eliom\_registration.Redirection** , ….

*type block\_content*

The type  **block\_content** is a refinement of  **Eliom\_registration.http\_service** to be used as a phantom type parameters for  **Eliom\_registration.kind** . It means the returned content is a subtree of an XML value. See for example  **Block5** or  **Eliom\_registration.Make\_typed\_xml\_registration** .

*type unknown\_content*

The type  **unknown\_content** is a refinement of  **Eliom\_registration.http\_service** to be used as a phantom type parameters for  **Eliom\_registration.kind** when the content-type can't be determined staticaly. See  **Text** or **Eliom\_registration.Any** .

**===** **Application content** **===**

*type appl\_service* =  **Eliom\_service.appl\_service**

The type  **appl\_service** is used as a phantom type parameters for **Eliom\_service.service** and  **Eliom\_registration.kind** . It means the service is part of an Eliom application. See  **Eliom\_registration.kind** for a list of others return types.

*type* **'a** *application\_content* =  **\[ \`Appl of 'a \]**

The type  **application\_content** is a refinement of  **Eliom\_registration.appl\_service** to be used as a phantom type parameters for  **Eliom\_registration.kind** . The parameter  **'a** is phantom type that is unique for a given application.

**===** **OCaml content** **===**

*type* **'a** *ocaml\_content*

The type  **ocaml\_content** is an synomyn for  **Eliom\_service.ocaml\_service** to be used as a phantom type parameters for  **Eliom\_registration.kind** . See **Eliom\_registration.Ocaml** .

*type non\_ocaml\_service* =  **Eliom\_service.non\_ocaml\_service**

The type  **non\_ocaml\_service** is used as phantom type parameters for the  **Eliom\_registration.kind** . It used to type functions that operates over service that do not returns OCaml values, like **Eliom\_registration.appl\_self\_redirect** .

**===** **Module signature** **===**

*module type Registration =* **sig end**

Abstract signature for service registration functions. For concrete instance see  **Eliom\_registration.Html5** ,  **Eliom\_registration.CssText** ,  **Eliom\_registration.File** , **Eliom\_registration.Redirection** , …

**===** **Using HTML5 with services** **===**

*module Html5\_registration :* **sig end**

Eliom service registration for services that returns HTML5 page. This is a subset of the  **Eliom\_registration.Html5** module and an instance of the  **Eliom\_registration.Registration** abstract signature.

*module Html5 :* **sig end**

Eliom service registration for HTML5 page. This an instance the  **Eliom\_registration.Registration** abstract signatures.

**===** **Eliom client/server applications** **===**

*module type APPL\_PARAMS =* **sig end**

Signature for application creation.

*type appl\_service\_options* = {\
  do\_not\_launch :  **bool** ;\
  }

Type for the options of an Eliom application service.

If you set  **do\_not\_launch** to  **true** when creating an application service, it will send the page without launching the client side program. However, if the program is already lanched, the client side process won't be stopped. Use this if some of your pages are not using the client side program and you want to make them load faster.

**=== Do not launch the client side program if it is not already** **launched. Default: false. ===**

*val default\_appl\_service\_options* :  **appl\_service\_options**

The default options record for an eliom service. See **Eliom\_registration.appl\_service\_options** .

*module type ELIOM\_APPL =* **sig end**

*module App :* **functor (Appl\_params : APPL\_PARAMS) -\> ELIOM\_APPL**

Functor for application creation. The resulting module is an instance of the  **Eliom\_registration.Registration** abstract signature.

*module type TMPL\_PARAMS =* **sig end**

*module Eliom\_tmpl :* **functor (Appl : ELIOM\_APPL) -\> functor (Tmpl\_param : TMPL\_PARAMS) -\> sig end**

**===** **Services returning only fragment of HTML (or others TyXML tree)** **===**

*module Flow5 :* **sig end**

Eliom service registration and forms creation for fragment of HTML5 page. This is an instance of the  **Eliom\_registration.Registration** abstract signature.

For Eliom application, prefers  **Eliom\_registration.Ocaml** services to send page fragments.

*module Make\_typed\_xml\_registration :* **functor (Xml : Xml\_sigs.Iterable) -\>** **functor (Typed\_xml : sig end) -\> functor (E : sig end) -\> sig end**

Eliom service registration for services that returns fragment of TyXML's tree. The returned module is an instance of the **Eliom\_registration.Registration** abstract signature.

**===** **Untyped pages** **===**

*module Html\_text :* **sig end**

Eliom service registration and forms creation for untyped HTML page. This an instance the  **Eliom\_registration.Registration** abstract signature. The page content is a  **string** that must contains valid HTML and the content type is always  **text/html** .

*module CssText :* **sig end**

Eliom service registration for services that returns CSS. The page content is a  **string** that must contains valid CSS and the content type is always  **text/css** . The option is the optional "Cache-policy: max-age" header value to be sent.

This an instance of the  **Eliom\_registration.Registration** abstract signature.

**===** **Other kinds of services** **===**

*module Action :* **sig end**

Eliom service registration for services that only execute actions. See the Eliom manual for more information about .

If you give the optional parameter  **~options:\`NoReload** to the registration function, the action will executed and a  **204 No** **Content** will be sent to the server.

This an instance of the  **Eliom\_registration.Registration** abstract signature.

*module Unit :* **sig end**

Similar to  **Actions** with  **\`NoReload** option.

*module Redirection :* **sig end**

Eliom service registration for services that returns a redirections towards another service. See the Eliom manual for more information about .

The default returned HTTP code is  **302 Found** . You could use the optional parameter  **~options** to change this value:

\- **\`MovedPermanently** to return  **301 Moved Permanently** .

\- **\`Found** to return  **302 Found** .

\- **\`SeeOther** to return  **303 See Other** .

\- **\`NotNodifed** to return  **304 Not Modified** .

\- **\`UseProxy** to return  **305 Use Proxy** .

\- **\`TemporaryRedirect** to return  **307 Temporary Redirect** .

*module String\_redirection :* **sig end**

Eliom service registration for services that returns a redirections towards a string-URL. See the Eliom manual for more information about . The URL given must be an absolute URI.

The default returned HTTP code is  **302 Found** . You could use the optional parameter  **~options** to change this value, see **Redirections** for a detailled description.

This an instance of the  **Eliom\_registration.Registration** abstract signature.

*module File :* **sig end**

Eliom service registration for services that returns file contents. The value returned by service handlers is the name of the file to send. See the Eliom manual for more information on . The option is the optional "Cache-policy: max-age" header value to be sent.

*module File\_ct :* **sig end**

Same as file but makes possible to specify the content type for each file. The value returned by service handlers is a pair **(file\_name, content\_type)**

*module Ocaml :* **sig end**

Eliom service registration for services that send marshalled OCaml values.

This an instance of the  **Eliom\_registration.Registration** abstract signature.

*module Any :* **sig end**

Eliom service registration for services that choose dynamically what they want to send. The content is created using for example **Eliom\_registration.Html5.send** or  **Eliom\_registration.String.send** functions. See the Eliom manual for more information about

*val appl\_self\_redirect* :  **('page -\> \[\< \`Appl of 'a \| \`Browser \] kind Lwt.t) -\>** **'page -\>** **'appl application\_content kind Lwt.t**

The function  **appl\_self\_redirect send page** is an helper function required for defining  **Eliom\_registration.Any** service usable inside an Eliom application ( **Eliom\_registration.App** ). It allows casting an Eliom senders that do not returns  **Eliom\_registration.application\_content** (like  **Eliom\_registration.File.send** , **Eliom\_registration.String.send** , ...) into a senders returns **Eliom\_registration.application\_content** .

When the service is called from an Eliom application, this is implemented with half-redirection (a redirection that leaves the application). Hence, the service may be called two times in a row and you should not use this function for service that use POST parameters.

*module String :* **sig end**

Eliom service registration for services that returns "byte"-string contents. The page content is a pair  **(raw\_content,** **content\_type)** . See also  **Eliom\_registration.Streamlist** for another kind of service that returns "byte" contents. The option is the optional "Cache-policy: max-age" header value to be sent.

This an instance of the  **Eliom\_registration.Registration** abstract signature.

*module Streamlist :* **sig end**

Eliom service registration for services that returns "byte" contents with . The page content is a pair **(stream\_creator\_list, content\_type)** . See also  **Eliom\_registration.String** for another kind of service that returns "byte" contents.

Streams are created by calling the functions in the list and  is called at the end of the stream. If something goes wrong while processing a stream, the current stream is closed and the following streams are not created.

**===** **Customizing registration** **===**

*module Customize :* **functor (R : Registration) -\> functor (T : sig end) -\> sig end**

The  **Customize** functor allows specialization of service registration functions by customizing the page type. See the  for example.

**===** **Using your own error pages** **===**

*val set\_exn\_handler* :  **(exn -\> browser\_content kind Lwt.t) -\>** **unit**

The  **set\_exn\_handler handler** allows redefinition of error pages: **404** or any exception during page generation.

Note that you should not catch every exception here since some Eliom mechanisms are done using exceptions, like redirections. Do not catch exception defined in Eliom except  **Eliom\_common.Eliom\_404** , **Eliom\_common.Eliom\_Wrong\_parameter** **Eliom\_common.Eliom\_Typing\_Error** .

Warning: This 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.

*val cast\_unknown\_content\_kind* :  **unknown\_content kind -\>** **'a kind**

**Unsafe cast of contents**

*val cast\_http\_result* :  **Ocsigen\_http\_frame.result -\> 'a kind**

If you know that the content you generated using  **Text.send** or **Streamlist.send** is the same as some other kind, you can cast it with  **cast\_unknown\_content\_kind** for use with  **Any** module.
