2016-12-01 21:27:53 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
(** Typed RPC services: server implementation. *)
|
|
|
|
|
|
|
|
(** A handle on the server worker. *)
|
|
|
|
type server
|
|
|
|
|
2016-12-14 19:40:42 +04:00
|
|
|
(** Promise a running RPC server. To call an RPC at /p/a/t/h/ in the
|
2016-12-02 01:00:45 +04:00
|
|
|
provided service, one must call the URI /call/p/a/t/h/. Calling
|
|
|
|
/list/p/a/t/h/ will list the services prefixed by /p/a/t/h/, if
|
|
|
|
any. Calling /schema/p/a/t/h/ will describe the input and output
|
|
|
|
of the service, if it is callable. Calling /pipe will read a
|
|
|
|
sequence of services to call in sequence from the request body,
|
|
|
|
see {!pipe_encoding}.
|
2016-12-01 21:27:53 +04:00
|
|
|
|
2016-12-06 16:58:21 +04:00
|
|
|
The arguments cors_allowed_origins and cors_allowed_headers define
|
|
|
|
the cross-origin resource sharing using the headers
|
|
|
|
Access-Control-Allow-Origin and Access-Control-Allow-Headers. The
|
|
|
|
argument cors_allowed_headers sets the content of
|
|
|
|
Access-Control-Allow-Headers. Since you cannot have multiple
|
|
|
|
values for Access-Control-Allow-Origin, the server accepts a list
|
|
|
|
in cors_allowed_origins and matches it against the origin of the
|
|
|
|
incoming request; then returns the longest element of the passed
|
|
|
|
list as the content of Access-Control-Allow-Origin.
|
|
|
|
|
2016-12-01 21:27:53 +04:00
|
|
|
The optional [pre_hook] is called with the path part of the URL
|
|
|
|
before resolving each request, to delegate the answering to
|
|
|
|
another resolution mechanism. Its result is ignored if the return
|
|
|
|
code is [404]. The optional [post_hook] is called if both the
|
|
|
|
[pre_hook] and the serviced answered with a [404] code. *)
|
2016-12-13 04:52:55 +04:00
|
|
|
val launch :
|
2016-12-01 21:27:53 +04:00
|
|
|
?pre_hook: (string -> string RPC.Answer.answer Lwt.t) ->
|
|
|
|
?post_hook: (string -> string RPC.Answer.answer Lwt.t) ->
|
2016-12-13 04:52:55 +04:00
|
|
|
?host:string ->
|
|
|
|
Conduit_lwt_unix.server ->
|
2016-12-06 16:58:21 +04:00
|
|
|
unit RPC.directory ->
|
|
|
|
string list ->
|
|
|
|
string list ->
|
|
|
|
server Lwt.t
|
2016-12-01 21:27:53 +04:00
|
|
|
|
2016-12-14 19:40:42 +04:00
|
|
|
(** Kill an RPC server. *)
|
2016-12-01 21:27:53 +04:00
|
|
|
val shutdown : server -> unit Lwt.t
|
|
|
|
|
2016-12-02 01:00:45 +04:00
|
|
|
(** Retrieve the root service of the server. *)
|
2016-12-01 21:27:53 +04:00
|
|
|
val root_service : server -> unit RPC.directory
|
|
|
|
|
2016-12-02 01:00:45 +04:00
|
|
|
(** Change the root service of the server. *)
|
2016-12-01 21:27:53 +04:00
|
|
|
val set_root_service : server -> unit RPC.directory -> unit
|