This is client API (go to server)

Module Eliom_service.​Http

module Http : sig..end

Default module for creating services


Definitions of services

Warning: These 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.

Main services

val service : 
  ?rt:'rt Eliom_service.rt ->
  ?https:bool ->
  path:Eliom_lib.Url.path ->
  ?keep_nl_params:[ `All | `None | `Persistent ] ->
  ?priority:int ->
  get_params:('get, [< Eliom_service.suff ] as 'a, 'gn)
   Eliom_parameter.params_type ->
  unit ->
  ('get, unit,
   [> `Attached of
   ([> `Internal of [> `Service ] ], [> `Get ]) Eliom_service.a_s ],
   'a, 'gn, unit, [< Eliom_service.registrable > `Registrable ],
   [> Eliom_service.http_service ])
  Eliom_service.service

The function service ~path ~get_params () creates a Eliom_service.​Http.​service associated to the path path and taking get_params as GET parameters.

If the optional parameter ~https:true is given, all links towards that service will use https. By default, links will keep the current protocol.

The optional parameter ~priority allows one to change the priority order between service that shares 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.

If the optional parameter ~keep_nl_params:`Persistent (resp. ~keep_nl_params:`All) is given, all links towards that service will keep persistent (resp. all) non localized GET parameters of the current service. The default is `None. See the eliom manual for more information about non localized parameters.

The optional paramater ?rt is used to constrain the type parameter 'rt of the returned service if is 'rt Eliom_service.caml_service. Example: service ~rt:(Eliom_service.rt : your_return_type Eliom_service.rt).

val post_service : 
  ?rt:'rt Eliom_service.rt ->
  ?https:bool ->
  fallback:('get, unit,
   [ `Attached of
   ([ `Internal of [ `Coservice | `Service ] ], [ `Get ])
   Eliom_service.a_s ],
   [< Eliom_service.suff ] as 'a, 'gn, unit, [< `Registrable ],
   [< Eliom_service.non_ocaml_service ])
   Eliom_service.service ->
  ?keep_nl_params:[ `All | `None | `Persistent ] ->
  ?priority:int ->
  post_params:('post, [ `WithoutSuffix ], 'pn)
   Eliom_parameter.params_type ->
  unit ->
  ('get, 'post,
   [> `Attached of
   ([> `Internal of [ `Coservice | `Service ] ], [> `Post ])
   Eliom_service.a_s ],
   'a, 'gn, 'pn, [< Eliom_service.registrable > `Registrable ],
   [> Eliom_service.http_service ])
  Eliom_service.service

The function post_service ~fallback ~post_params () creates a service that takes post_params as POST parameters and share the same path and GET parameters than the service fallback.

POST parameters couldn't contain a suffix parameter.

The service fallback should be an (internal) attached service without POST parameters ; it couldn't be a preapplied service. This argument enforces the creation of an equivalent service ( i.e. a service with the same path and GET parameters ) to be served when POST parameters are missing. Thus, the user cannot put a bookmark on a page that does not exist.

See Eliom_service.​Http.​service for a description of optional ~https, ~keep_nl_params, ~priority and ~rt parameters .

Attached coservices

val coservice : 
  ?rt:'rt Eliom_service.rt ->
  ?name:string ->
  ?csrf_safe:bool ->
  ?csrf_scope:[< Eliom_common.user_scope ] ->
  ?csrf_secure:bool ->
  ?max_use:int ->
  ?timeout:float ->
  ?https:bool ->
  fallback:(unit, unit,
   [ `Attached of
   ([ `Internal of [ `Service ] ], [ `Get ])
   Eliom_service.a_s ],
   [ `WithoutSuffix ], unit, unit,
   [< Eliom_service.registrable ],
   [< Eliom_service.non_ocaml_service ])
   Eliom_service.service ->
  ?keep_nl_params:[ `All | `None | `Persistent ] ->
  get_params:('get, [ `WithoutSuffix ], 'gn) Eliom_parameter.params_type ->
  unit ->
  ('get, unit,
   [> `Attached of
   ([> `Internal of [> `Coservice ] ], [> `Get ]) Eliom_service.a_s ],
   [ `WithoutSuffix ], 'gn, unit,
   [< Eliom_service.registrable > `Registrable ],
   [> Eliom_service.http_service ])
  Eliom_service.service

The function coservice ~fallback ~get_params creates an attached coservice at the same path than the service fallback and taking get_params as GET parameters.

GET parameters of coservice couldn't contain a suffix parameter.

The service fallback should be an (internal) attached service without any GET or POST parameters ; it could be a preapplied service.

The optional ~name parameter Coservices can be named if the ?name optional parameter is present or anonymous (in that case, a coservice number will be generated).

The optional ~timeout parameter 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 parameter specifies that the service can be used only a fixed number of times. The default is "no limitation".

If the optional ~csrf_safe parameter is true, it will create a "CSRF-safe" service. In that case the ~name parameter is ignored. The default is false.

The ~csrf_scope and ~csrf_secure, if present, should respectively correspond to the ~scope and ~secure parameters that will be given to the associated register function. Otherwise the registration will fail with . See Eliom_registration.Html5.register, Eliom_registration.App.register or any other Eliom_registration.*.register functions for a description of those parameters.

See Eliom_service.​Http.​service for a description of the optional ~https, ~rt and ~keep_nl_params parameters .

val post_coservice : 
  ?rt:'rt Eliom_service.rt ->
  ?name:string ->
  ?csrf_safe:bool ->
  ?csrf_scope:[< Eliom_common.user_scope ] ->
  ?csrf_secure:bool ->
  ?max_use:int ->
  ?timeout:float ->
  ?https:bool ->
  fallback:('get, unit,
   [ `Attached of
   ([ `Internal of [< `Coservice | `Service ] ], [ `Get ])
   Eliom_service.a_s ],
   [< Eliom_service.suff ] as 'a, 'gn, unit, [< `Registrable ],
   [< Eliom_service.non_ocaml_service ])
   Eliom_service.service ->
  ?keep_nl_params:[ `All | `None | `Persistent ] ->
  post_params:('post, [ `WithoutSuffix ], 'pn)
   Eliom_parameter.params_type ->
  unit ->
  ('get, 'post,
   [> `Attached of
   ([> `Internal of [> `Coservice ] ], [> `Post ])
   Eliom_service.a_s ],
   'a, 'gn, 'pn, [< Eliom_service.registrable > `Registrable ],
   [> Eliom_service.http_service ])
  Eliom_service.service

The function post_coservice ~fallback ~post_params creates an attached coservice with the same path and GET parameters than the service fallback and taking post_params as POST parameters.

POST parameters couldn't contain a suffix parameter.

The service fallback should be an (internal) attached service or coservice without any POST parameters ; it could be a preapplied service.

See Eliom_service.​Http.​coservice for a description of optional parameters.

Non attached coservices

val coservice' : 
  ?rt:'rt Eliom_service.rt ->
  ?name:string ->
  ?csrf_safe:bool ->
  ?csrf_scope:[< Eliom_common.user_scope ] ->
  ?csrf_secure:bool ->
  ?max_use:int ->
  ?timeout:float ->
  ?https:bool ->
  ?keep_nl_params:[ `All | `None | `Persistent ] ->
  get_params:('get, [ `WithoutSuffix ], 'gn) Eliom_parameter.params_type ->
  unit ->
  ('get, unit, [> `Nonattached of [> `Get ] Eliom_service.na_s ],
   [ `WithoutSuffix ], 'gn, unit,
   [< Eliom_service.registrable > `Registrable ],
   [> Eliom_service.http_service ])
  Eliom_service.service

The function coservice' ~get_param creates a non-attached coservice taking get_params as extra GET parameters.

GET parameters of coservice' couldn't contain a suffix parameter.

See Eliom_service.​Http.​service for a description of the optional ~https, ~rt and ~keep_nl_params parameters ; see Eliom_service.​Http.​coservice for others optional parameters.

val post_coservice' : 
  ?rt:'rt Eliom_service.rt ->
  ?name:string ->
  ?csrf_safe:bool ->
  ?csrf_scope:[< Eliom_common.user_scope ] ->
  ?csrf_secure:bool ->
  ?max_use:int ->
  ?timeout:float ->
  ?https:bool ->
  ?keep_nl_params:[ `All | `None | `Persistent ] ->
  ?keep_get_na_params:bool ->
  post_params:('post, [ `WithoutSuffix ], 'pn)
   Eliom_parameter.params_type ->
  unit ->
  (unit, 'post, [> `Nonattached of [> `Post ] Eliom_service.na_s ],
   [ `WithoutSuffix ], unit, 'pn,
   [< Eliom_service.registrable > `Registrable ],
   [> Eliom_service.http_service ])
  Eliom_service.service

The function post_coservice' ~post_params creates a non-attached coservice taking post_params as POST parameters.

POST parameters couldn't contain a suffix parameter.

If the optional parameter ~keep_get_na_params is false, GET non-attached parameters of the current page won't be kept in the URL (if any) when you create a POST form to this coservice. The default is true.

See Eliom_service.​Http.​service for a description of the optional ~https, ~rt and ~keep_nl_params parameters ; see Eliom_service.​Http.​coservice for others optional parameters.

val external_service : 
  prefix:string ->
  path:Eliom_lib.Url.path ->
  ?rt:'rt Eliom_service.rt ->
  ?keep_nl_params:[ `All | `None | `Persistent ] ->
  get_params:('get, [< Eliom_service.suff ] as 'a, 'gn)
   Eliom_parameter.params_type ->
  unit ->
  ('get, unit,
   [> `Attached of ([> `External ], [> `Get ]) Eliom_service.a_s ], 'a,
   'gn, unit, [< Eliom_service.registrable > `Unregistrable ],
   [> Eliom_service.http_service ])
  Eliom_service.service

The function external_service ~prefix ~path ~get_params () creates a service for an external web site, that will use GET method and requires get_params as parameters. This allows one to creates links or forms towards other Web sites using Eliom's syntax.

The parameter labelled ~path is the URL path. Each element of the list will be URL-encoded.

The parameter labelled ~prefix contains all what you want to put before the path. It usually starts with "http://" plus the name of the server. The prefix is not URL encoded.

The whole URL is constructed from the prefix, the path and GET parameters. Hence, an empty prefix can be used to make a link to another site of the same server.

See Eliom_service.​Http.​service for a description of the optional ~keep_nl_params and ~rt parameters.

val external_post_service : 
  prefix:string ->
  path:Eliom_lib.Url.path ->
  ?rt:'rt Eliom_service.rt ->
  ?keep_nl_params:[ `All | `None | `Persistent ] ->
  get_params:('get, [< Eliom_service.suff ] as 'a, 'gn)
   Eliom_parameter.params_type ->
  post_params:('post, [ `WithoutSuffix ], 'pn)
   Eliom_parameter.params_type ->
  unit ->
  ('get, 'post,
   [> `Attached of ([> `External ], [> `Post ]) Eliom_service.a_s ], 'a,
   'gn, 'pn, [< Eliom_service.registrable > `Unregistrable ],
   [> Eliom_service.http_service ])
  Eliom_service.service

Same as Eliom_service.​Http.​external_service but with POST method.