This is server API (go to client)

Module Eliom_output

module Eliom_output : sig..end

Eliom services registration and forms creation for various kind of page content: Eliom application, valid HTML5 or XHTML, actions, redirections, static files, …. See the Eliom manual for more information on services and predefined outputs .


Type definitions

type ('a, 'b) 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:

Return types for Eliom_services.​service

Classical content

type http_service = [ `Http ]

The type http_service is used as a phantom type parameters for Eliom_services.​service and Eliom_output.​kind. It means the returned content is classical HTTP content described by the content type header. See Eliom_output.​kind for a list of others return types.

type browser_content = [ `Browser ]

The type browser_content is a refinement of Eliom_output.​http_service to be used as a phantom type parameters for Eliom_output.​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_output.​Html5, Eliom_output.​Xhtml, Eliom_output.​CssText, Eliom_output.​Files, Eliom_output.​Redirection, ….

type block_content

The type block_content is a refinement of Eliom_output.​http_service to be used as a phantom type parameters for Eliom_output.​kind. It means the returned content is a subtree of an XML value. See for example Eliom_output.​Blocks5 or Eliom_output.​Make_TypedXML_Registration.

type unknown_content

The type unknown_content is a refinement of Eliom_output.​http_service to be used as a phantom type parameters for Eliom_output.​kind when the content-type can't be determined staticaly. See Eliom_output.​Text or Eliom_output.​Any.

Application content

type appl_service = [ `Appl ]

The type appl_service is used as a phantom type parameters for Eliom_services.​service and Eliom_output.​kind. It means the service is part of an Eliom application. See Eliom_output.​kind for a list of others return types.

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

The type application_content is a refinement of Eliom_output.​appl_service to be used as a phantom type parameters for Eliom_output.​kind. The parameter 'a is phantom type that is unique for a given application.

OCaml content

type 'a caml_content

The type caml_content is an synomyn for Eliom_parameters.​caml to be used as a phantom type parameters for Eliom_output.​kind. See Eliom_output.​Caml.

type non_caml_service = [ `Appl | `Http ]

The type non_caml_service is used as phantom type parameters for the Eliom_output.​kind. It used to type functions that operates over service that do not returns OCaml values, like Eliom_output.​appl_self_redirect.

Module signature

module type Registration = sig..end

Abstract signature for service registration functions.

module type Forms = sig..end

Abstract signature for links and forms creation functions.

Using HTML5.M with services

module Html5 : sig..end

Eliom service registration and forms creation for HTML5 page.

module Html5_registration : sig..end

Eliom service registration for services that returns HTML5 page.

module Html5_forms : sig..end

Eliom forms creation for HTML5.

Using XHTML.M with services

module Xhtml : sig..end

Eliom service registration and forms creation for XHTML page.

module Xhtml_registration : sig..end

Eliom service registration for services that returns XHTML page.

module Xhtml_forms : sig..end

Eliom forms creation for XHTML page.

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_output.​appl_service_options.

module Eliom_appl : functor (Appl_params : APPL_PARAMS) -> 
  sig..end

Functor for application creation.

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.

module Blocks5 : sig..end

Deprecated alias for Eliom_output.​Flow5.

module Blocks : sig..end

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

module Make_TypedXML_Registration : functor (XML : XML_sigs.Iterable) -> 
  functor (TypedXML : XML_sigs.TypedXML     with module XML := XML) ->
  functor (E : sig      type contentend) ->
  sig..end

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

Untyped pages

module HtmlText : sig..end

Eliom service registration and forms creation for untyped HTML page.

module CssText : sig..end

Eliom service registration for services that returns CSS.

Other kinds of services

module Action : sig..end

Eliom service registration for services that only execute actions.

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.

module String_redirection : sig..end

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

module Files : sig..end

Eliom service registration for services that returns file contents.

module Caml : sig..end

Eliom service registration for services that send marshalled caml values.

module Any : sig..end

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

val appl_self_redirect : 
  ('a ->
   ([< `Appl of 'b | `Browser ], [< non_caml_service ])
   kind Lwt.t) ->
  'a ->
  ('c application_content, appl_service)
  kind Lwt.t

The function appl_self_redirect send page is an helper function required for defining Eliom_output.​Any service usable inside an Eliom application (Eliom_output.​Eliom_appl). It allows to cast an Eliom senders that do not returns Eliom_output.​application_content (like Eliom_output.​Files.​send, Eliom_output.​String.​send, ...) into a senders returns Eliom_output.​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.

module Text : sig..end

Deprecated alias for Eliom_output.​String.

module Streamlist : sig..end

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

Customizing registration

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

The Customize functor allows to specialize service registration functions by customizing the page type.

Using your own error pages

val set_exn_handler : 
  (exn ->
   (browser_content, http_service)
   kind Lwt.t) ->
  unit

The set_exn_handler handler allows to redefines 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_services.​register_eliom_module. Otherwise you will also get this exception.

val cast_unknown_content_kind : 
  (unknown_content, http_service)
  kind -> ('a, http_service) kind

Unsafe cast of contents

val cast_http_result : Ocsigen_http_frame.result -> ('a, 'b) 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.