Module Eliom_service

module Eliom_service: sig .. end
Functions to add non localised parameters to services and client side declaration of void coservices. Void coservices are the only ones defined on client side.


Type definitions for services



Services kind



The type service_kind describe all four kind of services:
type internal_attached_service_kind = [ `AttachedCoservice | `Service ] 
An internal attached service could either be a `Service or a `AttachedCoservice.
type internal_service_kind = [ `AttachedCoservice | `NonattachedCoservice | `Service ] 
An internal service could either be an internal attached service or a `NonattachedCoservice.
type service_kind = [ `AttachedCoservice | `External | `NonattachedCoservice | `Service ] 
An attached service could either be an internal Eliom service or an abstraction for an `External service.

Attached or Non-attached


type a_s 
The abstract type for attached service representation.
type na_s 
The abstract type for non-attached service representation.
type attached_kind = [ `Attached of a_s ] 
type non_attached_kind = [ `Nonattached of na_s ] 
type attached = [ `Attached of a_s | `Nonattached of na_s ] 

POST or GET parameters


type service_method = [ `Delete | `Get | `Post | `Put ] 
The kind of a service is `Post when there is at least one POST parameters. It is `Get otherwise.

Common subtypes of service_method


type get_service_kind = [ `Get ] 
Restriction of service_method to GET services.
type post_service_kind = [ `Post ] 
Restriction of service_method to POST services.
type put_service_kind = [ `Put ] 
Restriction of service_method to PUT services.
type delete_service_kind = [ `Delete ] 
Restriction of service_method to DELETE services.

Kind of parameters


type suff = [ `WithSuffix | `WithoutSuffix ] 
The kind of parameters for a service is `WithSuffix when it have a suffix parameter, for examples Eliom_parameter.suffix or Eliom_parameter.suffix_prod. Otherwise it is `WithoutSuffix.

Registrable service


type registrable = [ `Registrable | `Unregistrable ] 
A service is `Registrable only if it isn't a pre-applied service, see Eliom_service.preapply.

Abstract type of services


type ('get, 'post, +[< service_method ], +[< attached ]
, +[< service_kind ], +[< suff ], 'gn, 'pn
, +[< registrable ], +'ret)
service
Type of services.
type http_service = [ `Http ] 
Types of groups of services.
type appl_service = [ `Appl ] 
type +'a ocaml_service 
type non_ocaml_service = [ `Appl | `Http ] 
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 appl_self_redirect.
type 'rt rt 
Helper for typing OCaml services. In some cases, you may need to write the return type of the service manually. Instead of writing the full type of the service, (which may be huge), add a type constraint for parameter ?rt of service creation functions (like <<a_api subproject="server"|fun Eliom_service.Http.service>>), using the following value.
val rt : 'rt rt
module Unsafe: sig .. end
module App: sig .. end
Module for creating services that are applications
module Ocaml: sig .. end
Module for creating services that returns OCaml values
module Http: sig .. end
Default module for creating services

Predefined services



Static files


val static_dir : unit ->
(string list, unit, [< service_method > `Get ],
[< attached > `Attached ],
[< service_kind > `Service ], [ `WithSuffix ],
[ `One of string list ] Eliom_parameter.param_name, unit,
[< registrable > `Unregistrable ],
[> http_service ])
service
The predefined service static_dir allows one to create links to static files. This service takes the name of a static file as a parameter (a string list, slash separated). The actual directory in filesystem where static pages will be found must be set up in the configuration file with the staticmod extension.
val https_static_dir : unit ->
(string list, unit, [< service_method > `Get ],
[< attached > `Attached ],
[< service_kind > `Service ], [ `WithSuffix ],
[ `One of string list ] Eliom_parameter.param_name, unit,
[< registrable > `Unregistrable ],
[> http_service ])
service
Same as Eliom_service.static_dir but forcing https link.
val static_dir_with_params : ?keep_nl_params:[ `All | `None | `Persistent ] ->
get_params:('a, [ `WithoutSuffix ], 'an) Eliom_parameter.params_type ->
unit ->
(string list * 'a, unit, [< service_method > `Get ],
[< attached > `Attached ],
[< service_kind > `Service ], [ `WithSuffix ],
[ `One of string list ] Eliom_parameter.param_name * 'an, unit,
[< registrable > `Unregistrable ],
[> http_service ])
service
Like static_dir, but allows one to put GET parameters
val https_static_dir_with_params : ?keep_nl_params:[ `All | `None | `Persistent ] ->
get_params:('a, [ `WithoutSuffix ], 'an) Eliom_parameter.params_type ->
unit ->
(string list * 'a, unit, [< service_method > `Get ],
[< attached > `Attached ],
[< service_kind > `Service ], [ `WithSuffix ],
[ `One of string list ] Eliom_parameter.param_name * 'an, unit,
[< registrable > `Unregistrable ],
[> http_service ])
service
Same as Eliom_service.static_dir_with_params but forcing https link.
val void_coservice' : (unit, unit, [< service_method > `Get ],
[< attached > `Nonattached ],
[< service_kind > `NonattachedCoservice ], [ `WithoutSuffix ],
unit, unit, [< registrable > `Unregistrable ],
[> non_ocaml_service ])
service

Void non-attached coservices


val https_void_coservice' : (unit, unit, [< service_method > `Get ],
[< attached > `Nonattached ],
[< service_kind > `NonattachedCoservice ], [ `WithoutSuffix ],
unit, unit, [< registrable > `Unregistrable ],
[> non_ocaml_service ])
service
A predefined non-attached action with special behaviour: it has no parameter at all, even non-attached parameters. Use it if you want to make a link to the current page without non-attached parameters. It is almost equivalent to a POST non-attached service without POST parameters, on which you register an action that does nothing, but you can use it with <a> links, not only forms. It does not keep non attached GET parameters.
val void_hidden_coservice' : (unit, unit, [< service_method > `Get ],
[< attached > `Nonattached ],
[< service_kind > `NonattachedCoservice ], [ `WithoutSuffix ],
unit, unit, [< registrable > `Unregistrable ],
[> non_ocaml_service ])
service
The same, but forcing https.
val https_void_hidden_coservice' : (unit, unit, [< service_method > `Get ],
[< attached > `Nonattached ],
[< service_kind > `NonattachedCoservice ], [ `WithoutSuffix ],
unit, unit, [< registrable > `Unregistrable ], 'return)
service
Same as void_coservice' but keeps non attached GET parameters.

The same, but forcing https.

Miscellaneous


val preapply : service:('a, 'b, [< service_method ] as 'c,
[< attached > `Attached ] as 'd,
[< service_kind ] as 'g, [< suff ], 'e,
'f, [< registrable ], 'return)
service ->
'a ->
(unit, 'b, 'c, 'd, 'g, [ `WithoutSuffix ], unit, 'f,
[< registrable > `Unregistrable ], 'return)
service
The function preapply ~service paramaters creates a new service by preapplying service to the GET parameters. It is not possible to register a handler on an preapplied service ; preapplied services may be used in links or as fallbacks for coservices
val attach_coservice' : fallback:(unit, unit, [< `Get ], [< attached_kind ],
[< `AttachedCoservice | `Service ], [< suff ],
unit, unit, [< registrable ], 'return1)
service ->
service:('get, 'post, [< service_method ] as 'a,
[< non_attached_kind ], [< `NonattachedCoservice ],
[< `WithoutSuffix ] as 'b, 'gn, 'pn, [< registrable ],
'return)
service ->
('get, 'post, 'a, [< attached > `Attached ],
[< service_kind > `AttachedCoservice ], 'b, 'gn, 'pn,
[< registrable > `Unregistrable ], 'return)
service
attach_coservice' ~fallback ~service attaches the non-attached coservice service on the URL of fallback. This allows to create a link to a non-attached coservice but with another URL than the current one. It is not possible to register something on the service returned by this function.
val add_non_localized_get_parameters : params:('p, [ `WithoutSuffix ], 'pn) Eliom_parameter.non_localized_params ->
service:('a, 'b, [< service_method ] as 'c,
[< attached ] as 'd,
[< service_kind ] as 'g,
[< suff ] as 'h, 'e, 'f,
[< registrable ] as 'i, 'return)
service ->
('a * 'p, 'b, 'c, 'd, 'g, 'h, 'e * 'pn, 'f, 'i, 'return)
service

Localized parameters


val add_non_localized_post_parameters : params:('p, [ `WithoutSuffix ], 'pn) Eliom_parameter.non_localized_params ->
service:('a, 'b, [< service_method ] as 'c,
[< attached ] as 'd,
[< service_kind ] as 'g,
[< suff ] as 'h, 'e, 'f,
[< registrable ] as 'i, 'return)
service ->
('a, 'b * 'p, 'c, 'd, 'g, 'h, 'e, 'f * 'pn, 'i, 'return)
service
Adds non localized GET parameters to a service

Adds non localized POST parameters to a service

Static files


val static_dir : unit ->
(string list, unit, [< service_method > `Get ],
[< attached > `Attached ],
[< service_kind > `Service ], [ `WithSuffix ],
[ `One of string list ] Eliom_parameter.param_name, unit,
[< registrable > `Unregistrable ],
[> http_service ])
service
The predefined service static_dir allows one to create links to static files. This service takes the name of a static file as a parameter (a string list, slash separated). The actual directory in filesystem where static pages will be found must be set up in the configuration file with the staticmod extension.
val https_static_dir : unit ->
(string list, unit, [< service_method > `Get ],
[< attached > `Attached ],
[< service_kind > `Service ], [ `WithSuffix ],
[ `One of string list ] Eliom_parameter.param_name, unit,
[< registrable > `Unregistrable ],
[> http_service ])
service
Same as Eliom_service.static_dir but forcing https link.
val static_dir_with_params : ?keep_nl_params:[ `All | `None | `Persistent ] ->
get_params:('a, [ `WithoutSuffix ], 'an) Eliom_parameter.params_type ->
unit ->
(string list * 'a, unit, [< service_method > `Get ],
[< attached > `Attached ],
[< service_kind > `Service ], [ `WithSuffix ],
[ `One of string list ] Eliom_parameter.param_name * 'an, unit,
[< registrable > `Unregistrable ],
[> http_service ])
service
Like static_dir, but allows one to put GET parameters
val https_static_dir_with_params : ?keep_nl_params:[ `All | `None | `Persistent ] ->
get_params:('a, [ `WithoutSuffix ], 'an) Eliom_parameter.params_type ->
unit ->
(string list * 'a, unit, [< service_method > `Get ],
[< attached > `Attached ],
[< service_kind > `Service ], [ `WithSuffix ],
[ `One of string list ] Eliom_parameter.param_name * 'an, unit,
[< registrable > `Unregistrable ],
[> http_service ])
service
Same as Eliom_service.static_dir_with_params but forcing https link.