1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
type t = {
http_get_string :
env:Eio_unix.Stdenv.base ->
rpc_addr:string ->
app_bin_dir:string ->
string ->
(string, string) result;
http_get_url :
env:Eio_unix.Stdenv.base ->
rpc_addr:string ->
app_bin_dir:string ->
string ->
(string, string) result;
}
let key : t Miaou_interfaces.Capability.key =
Miaou_interfaces.Capability.create ~name:"miaou.net"
let create
~(http_get_string :
env:Eio_unix.Stdenv.base ->
rpc_addr:string ->
app_bin_dir:string ->
string ->
(string, string) result)
~(http_get_url :
env:Eio_unix.Stdenv.base ->
rpc_addr:string ->
app_bin_dir:string ->
string ->
(string, string) result) =
{http_get_string; http_get_url}
let register v = Miaou_interfaces.Capability.set key v
let get () = Miaou_interfaces.Capability.get key
let require () = Miaou_interfaces.Capability.require key
let http_get_string t ~rpc_addr ~app_bin_dir path =
match Miaou_helpers.Fiber_runtime.env_opt () with
| Some env -> t.http_get_string ~env ~rpc_addr ~app_bin_dir path
| None ->
Error
"Eio runtime not initialized; call Fiber_runtime.init inside \
Eio_main.run"
let http_get_url t ~rpc_addr ~app_bin_dir path =
match Miaou_helpers.Fiber_runtime.env_opt () with
| Some env -> t.http_get_url ~env ~rpc_addr ~app_bin_dir path
| None ->
Error
"Eio runtime not initialized; call Fiber_runtime.init inside \
Eio_main.run"