Page
Library
Module
Module type
Parameter
Class
Class type
Source
Client.MakeSourceMake(Encoding)(Client) is a module that allows you to make calls to various Resto (or EzResto) services.
The calls are type safe: you must provide the correct parameters to the services which are automatically encoded according to Encoding, the answer is automatically decoded according to Encoding. The scheduling (waiting on answers, etc.) is provided by Client.
module Encoding : Resto.ENCODINGServices.
Content-Type header specifications: https://tools.ietf.org/html/rfc7231#section-3.1.1.5 and additional information: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
type content =
Cohttp_lwt.Body.t
* content_type option
* Resto_cohttp.Media_type.Make(Encoding).t optiontype ('o, 'e) generic_rest_result = [ | `Ok of 'o option200
*)| `Conflict of 'e409
*)| `Error of 'e500
*)| `Forbidden of 'e403
*)| `Not_found of 'e404
*)| `Gone of 'e410
*)| `Bad_request of string400
*)| `Method_not_allowed of string list405
*)| `Unsupported_media_type415
*)| `Not_acceptable of string406
*)| `Unexpected_status_code of Cohttp.Code.status_code * contentHTTP status code set by server is invalid or unsupported by resto
*)| `Connection_failed of stringFailure at one of the levels lower than HTTP (e.g., network)
*)| `OCaml_exception of stringException raised whilst decoding the result.
*)| `Too_many_redirects of string310
*)| `Redirect_without_location of stringRedirect did not have a Location header
*) ]The type for possible results when calling over HTTP. Some results correspond to an HTTP return code, other results correspond to internal issues with resto.
val generic_call :
[< Resto.meth ] ->
?redirect_behaviour:redirect_behaviour ->
?headers:(string * string) list ->
?accept:Resto_cohttp.Media_type.Make(Encoding).t list ->
?body:Cohttp_lwt.Body.t ->
?media:Resto_cohttp.Media_type.Make(Encoding).t ->
Uri.t ->
(content, content) generic_rest_result Lwt.tLow-level call primitive: use only for making calls for which there is no service defined, prefer making call to a defined service.
type ('o, 'e) service_result = [ | ('o, 'e option) generic_rest_result| `Unexpected_content_type of raw_content| `Unexpected_content of
(string * Resto_cohttp.Media_type.Make(Encoding).t) * string| `Unexpected_error_content_type of raw_content| `Unexpected_error_content of
(string * Resto_cohttp.Media_type.Make(Encoding).t) * string ]The type for possible results when calling a service. This includes the possible HTTP results (see generic_rest_result and other service-specific errors.
val call_service :
Resto_cohttp.Media_type.Make(Encoding).t list ->
?redirect_behaviour:redirect_behaviour ->
?logger:logger ->
?headers:(string * string) list ->
?base:Uri.t ->
([< Resto.meth ], unit, 'p, 'q, 'i, 'o, 'e) Service.t ->
'p ->
'q ->
'i ->
(Resto.meth * Uri.t * ('o, 'e) service_result) Lwt.tcall_service media_types ?logger ?headers ?base service path_params query_params input makes a call to service with the parameters path_params, query_params, and input. It returns a result (or an error).
The OCaml type system guarantees that the parameters are as expected by the service.
val call_streamed_service :
Resto_cohttp.Media_type.Make(Encoding).t list ->
?redirect_behaviour:redirect_behaviour ->
?logger:logger ->
?headers:(string * string) list ->
?base:Uri.t ->
([< Resto.meth ], unit, 'p, 'q, 'i, 'o, 'e) Service.t ->
on_chunk:('o -> unit) ->
on_close:(unit -> unit) ->
'p ->
'q ->
'i ->
(Resto.meth * Uri.t * (unit -> unit, 'e) service_result) Lwt.tcall_streamed_service media_types ?logger ?headers ?base service ~on_chunk ~on_close path_params query_params input makes a call to service with the parameters path_params, query_params, and input. The values returned by the service are passed to the on_chunk callback, and when the server closes the connection the on_close callback is called.
The function returns a unit -> unit function that consumes the remainder of the input without side-effects. Call this function when you want to discard all the queued-up chunks.
The OCaml type system guarantees that the parameters are as expected by the service.