Service definition
The function create ~id ~path ()
creates a service (Eliom_service_sigs.S.t
) identified as per path
and accepting parameters as per meth
. See Eliom_service_sigs.S.path_option
and Eliom_service_sigs.TYPES.meth
for the respective arguments.
If path = Path p
, the service appears on path p
. Otherwise (No_path
), the service doesn't have its own path. Rather, the service responds on any path as long as an internal automatically-generated parameter is provided.
In addition to ~path
and ~meth
, create
accepts a series of optional arguments described below.
If ~https:true
is provided, all links towards that service will use HTTPS. By default, links will keep the current protocol.
The optional argument ~priority
allows one to change the priority order between services that share the same path. The default priority is 0. If you want the service to be tried before (resp. after) other services, put a higher (resp. lower) priority.
The remaining arguments are ignored for services identified by a path (constructor Path
).
The optional ~timeout
argument specifies a timeout (in seconds) after which the coservice will disappear. This amount of time is computed from the creation or from the last call to the service. The default is "no timeout". The optional ~max_use
argument specifies that the service can be used only a fixed number of times. The default is "no limitation".
If the optional argument ~keep_nl_params:`Persistent
(resp. ~keep_nl_params:`All
) is given, all links towards that service will keep persistent (resp. all) non localized GET arguments of the current service. The default is `None
. See the eliom manual for more information about <<a_manual
chapter="server-params" fragment="nonlocalizedparameters"|non localized
parameters>>
.
The optional ~name
argument provides a name for the service; otherwise, it will be anonymous (with an auto-generated internal name).
If the optional ~csrf_safe
argument is true
, we create a <<a_manual chapter="server-security" fragment="csrf"|"CSRF-safe"
service>>
. In that case the ~name
argument is ignored. The default is false
.
The ~csrf_scope
and ~csrf_secure
, if present, should respectively correspond to the ~scope
and ~secure
arguments that will be given to the associated register
function. Otherwise the registration will fail with Eliom_service.Wrong_session_table_for_CSRF_safe_coservice
. See Eliom_registration.Html.register
, Eliom_registration.App.register
or any other Eliom_registration
.*.register
functions for a description of these arguments.
Warning: create
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.