.TH "Eliom_registration" 3o 2012-06-11 OCamldoc "" .SH NAME Eliom_registration \- Eliom services registration for various kinds of page content: Eliom application, valid Eliom_registration.Html5 or Eliom_registration.Xhtml, actions, redirections, static files, … .SH Module Module Eliom_registration .SH Documentation .sp Module .BI "Eliom_registration" : .B sig end .sp Eliom services registration for various kinds of page content: Eliom application, valid .B Eliom_registration\&.Html5 or .B Eliom_registration\&.Xhtml , actions, redirections, static files, … .sp .sp .sp .sp .PP .B === See the Eliom manual for .B more information on {% <> %} and {% <> %}\&. === .PP .PP .B === {% <> %} === .PP .PP .B === .B Type definitions .B === .PP .I type .B ('a, 'b) .I kind .sp The type .B 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: .sp .sp \-The second parameter is the same as the last type parameters of the corresponding .B Eliom_service\&.service \&. Currently, one of the following types: .sp \- .B Eliom_registration\&.appl_service .sp \- .B Eliom_registration\&.http_service .sp \- .B Eliom_parameter\&.caml .sp \-The first parameter is a refinement of the second parameter\&. Currently, one of the following types: .sp \- .B Eliom_registration\&.application_content .sp \- .B Eliom_registration\&.browser_content .sp \- .B Eliom_registration\&.block_content .sp \- .B Eliom_registration\&.unknown_content .sp \- .B Eliom_registration\&.caml_content .sp .sp .PP .B === .B Return types for Eliom_service\&.service .B === .PP .PP .B === .B Classical content .B === .PP .I type http_service = .B [ `Http ] .sp The type .B http_service is used as a phantom type parameters for .B Eliom_service\&.service and .B Eliom_registration\&.kind \&. It means the returned content is classical HTTP content described by the content type header\&. See .B Eliom_registration\&.kind for a list of others return types\&. .sp .sp .I type browser_content = .B [ `Browser ] .sp The type .B browser_content is a refinement of .B Eliom_registration\&.http_service to be used as a phantom type parameters for .B 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 .B Eliom_registration\&.Html5 , .B Eliom_registration\&.Xhtml , .B Eliom_registration\&.CssText , .B Eliom_registration\&.File , .B Eliom_registration\&.Redirection , …\&. .sp .sp .I type block_content .sp The type .B block_content is a refinement of .B Eliom_registration\&.http_service to be used as a phantom type parameters for .B Eliom_registration\&.kind \&. It means the returned content is a subtree of an XML value\&. See for example .B Eliom_registration\&.Block5 or .B Eliom_registration\&.Make_typed_xml_registration \&. .sp .sp .I type unknown_content .sp The type .B unknown_content is a refinement of .B Eliom_registration\&.http_service to be used as a phantom type parameters for .B Eliom_registration\&.kind when the content\-type can\&'t be determined staticaly\&. See .B Eliom_registration\&.Text or .B Eliom_registration\&.Any \&. .sp .sp .PP .B === .B Application content .B === .PP .I type appl_service = .B [ `Appl ] .sp The type .B appl_service is used as a phantom type parameters for .B Eliom_service\&.service and .B Eliom_registration\&.kind \&. It means the service is part of an Eliom application\&. See .B Eliom_registration\&.kind for a list of others return types\&. .sp .sp .I type .B 'a .I application_content = .B [ `Appl of 'a ] .sp The type .B application_content is a refinement of .B Eliom_registration\&.appl_service to be used as a phantom type parameters for .B Eliom_registration\&.kind \&. The parameter .B \&'a is phantom type that is unique for a given application\&. .sp .sp .PP .B === .B OCaml content .B === .PP .I type .B 'a .I caml_content .sp The type .B caml_content is an synomyn for .B Eliom_parameter\&.caml to be used as a phantom type parameters for .B Eliom_registration\&.kind \&. See .B Eliom_registration\&.Ocaml \&. .sp .sp .I type non_caml_service = .B [ `Appl | `Http ] .sp The type .B non_caml_service is used as phantom type parameters for the .B Eliom_registration\&.kind \&. It used to type functions that operates over service that do not returns OCaml values, like .B Eliom_registration\&.appl_self_redirect \&. .sp .sp .PP .B === .B Module signature .B === .PP .I module type Registration = .B sig end .sp Abstract signature for service registration functions\&. For concrete instance see .B Eliom_registration\&.Html5 , .B Eliom_registration\&.Xhtml , .B Eliom_registration\&.CssText , .B Eliom_registration\&.File , .B Eliom_registration\&.Redirection , … .sp .sp .PP .B === .B Using HTML5 with services .B === .PP .I module Html5_registration : .B sig end .sp Eliom service registration for services that returns HTML5 page\&. This is a subset of the .B Eliom_registration\&.Html5 module and an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .I module Html5 : .B sig end .sp Eliom service registration for HTML5 page\&. This an instance the .B Eliom_registration\&.Registration abstract signatures\&. .sp .sp .PP .B === .B Using XHTML with services .B === .PP .I module Xhtml : .B sig end .sp Eliom service registration for XHTML page\&. This an instance the .B Eliom_registration\&.Registration abstract signatures\&. .sp .sp .I module Xhtml_registration : .B sig end .sp Eliom service registration for services that returns XHTML page\&. This is a subset of the .B Eliom_registration\&.Xhtml module and an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .PP .B === .B Eliom client/server applications .B === .PP .I module type APPL_PARAMS = .B sig end .sp Signature for application creation\&. .sp .sp .I type appl_service_options = { do_not_launch : .B bool ; } .sp Type for the options of an Eliom application service\&. .sp If you set .B do_not_launch to .B 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\&. .sp .sp .PP .B === Do not launch the client side program if it is not already .B launched\&. Default: false\&. === .PP .I val default_appl_service_options : .B appl_service_options .sp The default options record for an eliom service\&. See .B Eliom_registration\&.appl_service_options \&. .sp .sp .I module type ELIOM_APPL = .B sig end .sp .sp .I module App : .B functor (Appl_params : APPL_PARAMS) -> ELIOM_APPL .sp Functor for application creation\&. The resulting module is an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .I module type TMPL_PARAMS = .B sig end .sp .sp .I module Eliom_tmpl : .B functor (Appl : ELIOM_APPL) -> functor (Tmpl_param : TMPL_PARAMS) -> sig end .sp .sp .PP .B === .B Services returning only fragment of HTML (or others TyXML tree) .B === .PP .I module Flow5 : .B sig end .sp Eliom service registration and forms creation for fragment of HTML5 page\&. This is an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp For Eliom application, prefers .B Eliom_registration\&.Ocaml services to send page fragment\&. .sp .sp .I module Block5 : .B sig end .sp Deprecated alias for .B Eliom_registration\&.Flow5 \&. .sp .sp .I module Block : .B sig end .sp Eliom service registration and forms creation for fragment of XHTML page\&. This is an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .I module Make_typed_xml_registration : .B functor (Xml : Xml_sigs.Iterable) -> .B functor (Typed_xml : sig end) -> functor (E : sig end) -> sig end .sp Eliom service registration for services that returns fragment of TyXML\&'s tree\&. The returned module is an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .PP .B === .B Untyped pages .B === .PP .I module Html_text : .B sig end .sp Eliom service registration and forms creation for untyped HTML page\&. This an instance the .B Eliom_registration\&.Registration abstract signature\&. The page content is a .B string that must contains valid HTML and the content type is always .B text/html \&. .sp .sp .I module CssText : .B sig end .sp Eliom service registration for services that returns CSS\&. The page content is a .B string that must contains valid CSS and the content type is always .B text/css \&. The option is the optionnal "Cache\-policy: max\-age" header value to be sent\&. .sp This an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .PP .B === .B Other kinds of services .B === .PP .I module Action : .B sig end .sp Eliom service registration for services that only execute actions\&. See the Eliom manual for more information about \&. .sp If you give the optional parameter .B ~options:`NoReload to the registration function, the action will executed and a .B 204 No .B Content will be sent to the server\&. .sp This an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .I module Unit : .B sig end .sp Similar to .B Actions with .B `NoReload option\&. .sp .sp .I module Redirection : .B sig end .sp Eliom service registration for services that returns a redirections towards another service\&. See the Eliom manual for more information about \&. .sp The default returned HTTP code is .B 302 Found \&. You could use the optional parameter .B ~options to change this value: .sp .sp \- .B `MovedPermanently to return .B 301 Moved Permanently \&. .sp \- .B `Found to return .B 302 Found \&. .sp \- .B `SeeOther to return .B 303 See Other \&. .sp \- .B `NotNodifed to return .B 304 Not Modified \&. .sp \- .B `UseProxy to return .B 305 Use Proxy \&. .sp \- .B `TemporaryRedirect to return .B 301 Temporary Redirect \&. .sp .sp .I module String_redirection : .B sig end .sp 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\&. .sp The default returned HTTP code is .B 302 Found \&. You could use the optional parameter .B ~options to change this value, see .B Redirections for a detailled description\&. .sp This an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .I module File : .B sig end .sp Eliom service registration for services that returns file contents\&. The page is the name of the file to send\&. See the Eliom manual for more information on \&. .sp .sp .I module Ocaml : .B sig end .sp Eliom service registration for services that send marshalled caml values\&. .sp This an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .I module Any : .B sig end .sp Eliom service registration for services that choose dynamically what they want to send\&. The content is created using for example .B Eliom_registration\&.Html5\&.send or .B Eliom_registration\&.String\&.send functions\&. See the Eliom manual for more information about .sp .sp .I val appl_self_redirect : .B ('a -> .B ([< `Appl of 'b | `Browser ], [< non_caml_service ]) .B kind Lwt.t) -> .B 'a -> .B ('c application_content, appl_service) .B kind Lwt.t .sp The function .B appl_self_redirect send page is an helper function required for defining .B Eliom_registration\&.Any service usable inside an Eliom application ( .B Eliom_registration\&.App )\&. It allows to cast an Eliom senders that do not returns .B Eliom_registration\&.application_content (like .B Eliom_registration\&.File\&.send , .B Eliom_registration\&.String\&.send , \&.\&.\&.) into a senders returns .B Eliom_registration\&.application_content \&. .sp 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\&. .sp .sp .I module String : .B sig end .sp Eliom service registration for services that returns "byte"\-string contents\&. The page content is a couple .B (raw_content, .B content_type) \&. See also .B Eliom_registration\&.Streamlist for another kind of service that returns "byte" contents\&. The option is the optionnal "Cache\-policy: max\-age" header value to be sent\&. .sp This an instance of the .B Eliom_registration\&.Registration abstract signature\&. .sp .sp .I module Text : .B sig end .sp Deprecated alias for .B Eliom_registration\&.String \&. .sp .sp .I module Streamlist : .B sig end .sp Eliom service registration for services that returns "byte" contents with \&. The page content is a couple .B (stream_creator_list, content_type) \&. See also .B Eliom_registration\&.String for another kind of service that returns "byte" contents\&. .sp 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\&. .sp .sp .PP .B === .B Customizing registration .B === .PP .I module Customize : .B functor (R : Registration) -> functor (T : sig end) -> sig end .sp The .B Customize functor allows to specialize service registration functions by customizing the page type\&. See the for example\&. .sp .sp .PP .B === .B Using your own error pages .B === .PP .I val set_exn_handler : .B (exn -> .B (browser_content, http_service) .B kind Lwt.t) -> .B unit .sp The .B set_exn_handler handler allows to redefines error pages: .B 404 or any exception during page generation\&. .sp 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 .B Eliom_common\&.Eliom_404 , .B Eliom_common\&.Eliom_Wrong_parameter .B Eliom_common\&.Eliom_Typing_Error \&. .sp 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 .B 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 .B Eliom_service\&.register_eliom_module \&. Otherwise you will also get this exception\&. .sp .sp .I val cast_unknown_content_kind : .B (unknown_content, http_service) .B kind -> .B ('a, http_service) kind .sp .B Unsafe cast of contents .sp .sp .I val cast_http_result : .B Ocsigen_http_frame.result -> ('a, 'b) kind .sp If you know that the content you generated using .B Text\&.send or .B Streamlist\&.send is the same as some other kind, you can cast it with .B cast_unknown_content_kind for use with .B Any module\&. .sp .sp