This is server API (go to client)

Module Eliom_registration

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 services and predefined outputs .

Type definitions

type 'a kind

The type kind is an abstract type for the HTTP frame returned by a service. The type parameter indicates the content type, and is one of the following types:

Return types for Eliom_service.service

Classical content

type browser_content = [ `Browser ]

The type browser_content is to be used as a phantom type parameter 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 to be used as a phantom type parameter 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 to be used as a phantom type parameter for Eliom_registration.​kind when the content-type can't be determined statically. See Text or Eliom_registration.​Any.

Application content

type 'a application_content = [ `Appl of 'a ]

The type application_content is a refinement of 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.

Using HTML5 with services

module Html5 : 
  Eliom_reg_sigs.S
with type page = Html5_types.html Eliom_content.Html5.elt
and type options = unit
and type return = Eliom_service.non_ocaml
and type result = browser_content kind

Eliom service registration for services that return HTML5 pages.

Eliom client/server applications

module type APPL_PARAMS = sig..end

Signature for application creation.

type appl_service_options = {
  do_not_launch: bool;(* <<div class="odocwiki_info"|~Do not launch the client side program if it is not already
          launched~.  ~Default~: <<span class="odocwiki_inlinecode"|false>>~.
>> *)}

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.

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.

module type TMPL_PARAMS = sig..end
module Eliom_tmpl : functor (Appl : ELIOM_APPL) -> 
  functor (Tmpl_param : TMPL_PARAMS) ->
  
  Eliom_reg_sigs.S
with type page = Tmpl_param.t
and type options = appl_service_options
and type return = Eliom_service.non_ocaml
and type result = Appl.app_id application_content kind

Services returning only fragments of HTML (or other TyXML

trees)===

module Flow5 : 
  Eliom_reg_sigs.S
with type page = Html5_types.flow5 Eliom_content.Html5.elt list
and type options = unit
and type return = Eliom_service.non_ocaml
and type result = block_content kind

Eliom service registration and forms creation for fragment of HTML5 page.

module Make_typed_xml_registration : functor (Xml : Xml_sigs.Iterable) -> 
  functor (Typed_xml : Xml_sigs.Typed_xml     with module Xml := Xml) ->
  functor (E : sig      type contentend) ->
  
  Eliom_reg_sigs.S
with type page = E.content Typed_xml.elt list
and type options = unit
and type return = Eliom_service.non_ocaml
and type result = block_content kind

Eliom service registration for services that returns fragment of TyXML's tree.

Untyped pages

module Html_text : 
  Eliom_reg_sigs.S
with type page = string
and type options = unit
and type return = Eliom_service.non_ocaml
and type result = browser_content kind

Eliom service registration and forms creation for untyped HTML page.

module CssText : 
  Eliom_reg_sigs.S
with type page = string
and type options = int
and type return = Eliom_service.non_ocaml
and type result = browser_content kind

Eliom service registration for services that returns CSS.

Other kinds of services

module Action : 
  Eliom_reg_sigs.S
with type return = Eliom_service.non_ocaml
and type page = unit
and type options = [ `Reload | `NoReload ]
and type result = browser_content kind

Eliom service registration for services that only execute actions.

module Unit : 
  Eliom_reg_sigs.S
with type page = unit
and type options = unit
and type return = Eliom_service.non_ocaml
and type result = browser_content kind

Similar to Actions with `NoReload option.

type '_ redirection =  | Redirection of 
    (unit, unit, Eliom_service.get, 'b, 'c, 'd, 'e,
     [ `WithoutSuffix ], unit, unit, 'a)
    Eliom_service.t

Auxiliarry type to hide non-interesting type parameters

module Redirection : sig..end

Eliom service registration for services that returns a redirections towards another service.

module String_redirection : 
  Eliom_reg_sigs.S
with type page = Eliom_lib.Url.uri
and type options =
[ `MovedPermanently
| `Found
| `SeeOther
| `NotNodifed
| `UseProxy
| `TemporaryRedirect ]
and type return = Eliom_service.non_ocaml
and type result = browser_content kind

Eliom service registration for services that returns a redirections towards a string-URL.

module File : sig..end

Eliom service registration for services that returns file contents.

module File_ct : sig..end

Same as file but makes possible to specify the content type for each file.

module Ocaml : 
  Eliom_reg_sigs.S_poly_with_send
with type 'a page = 'a
and type options = unit
and type 'a return = 'a Eliom_service.ocaml
and type 'a result = 'a ocaml_content kind

Eliom service registration for services that send marshalled OCaml values.

module Any : 
  Eliom_reg_sigs.S_poly_with_send
with type 'a page = 'a kind
and type options = unit
and type 'a return = Eliom_service.non_ocaml
and type 'a result = 'a kind

Eliom service registration for services that choose dynamically what they want to send.

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 File.send, 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 : 
  Eliom_reg_sigs.S
with type page = string * string
and type options = int
and type return = Eliom_service.non_ocaml
and type result = unknown_content kind

Eliom service registration for services that returns "byte"-string contents.

module Streamlist : 
  Eliom_reg_sigs.S
with type page =
(unit -> string Ocsigen_stream.t Lwt.t) list * string
and type options = unit
and type return = Eliom_service.non_ocaml
and type result = unknown_content kind

Eliom service registration for services that returns "byte" contents with Ocsigen's streams.

Customizing registration

module Customize : functor (R : Eliom_reg_sigs.S) -> 
  functor (T : sig      type page      val translate : page -> R.page Lwt.tend) ->
  
  Eliom_reg_sigs.S
with type options = R.options
and type return = R.return
and type page = T.page
and type result = R.result

The Customize functor allows specialization of service registration functions by customizing the page type.

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.

Unsafe cast of contents

val cast_unknown_content_kind : 
  unknown_content kind ->
  '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.

val cast_http_result : Ocsigen_http_frame.result -> 'a kind

cast_http_result should only be used to register new output modules