@@ -58,39 +58,71 @@ let read (dec : 'a Decoders_yojson.Basic.Decode.decoder)
58
58
read_error body
59
59
|> CCResult. flat_map (fun err -> Error (`Error_response (status, err)))
60
60
61
- (* let net =
62
- let open Eio.Std in
63
- let net = Eio_mock.Net.make "mocknet" in
64
- Eio_mock.Net.on_getaddrinfo net
65
- [ `Return [ `Tcp (Eio.Net.Ipaddr.V4.loopback, 443) ] ];
66
- let conn = Eio_mock.Flow.make "connection" in
67
- Eio_mock.Net.on_connect net [ `Return conn ];
68
- net *)
69
-
70
- let eval (c : Config.t ) (req : Api.Request.eval_req_src ) ~sw cl =
61
+ let eval (c : Config.t ) (req : Api.Request.eval_req_src ) ~sw ~client =
71
62
let uri = build_uri c " /eval/by-src" in
72
63
let headers = default_headers c |> Cohttp.Header. of_list in
73
64
let body = make_body E.Request. eval_req_src req in
74
- let res = Cohttp_eio.Client. call cl ~sw `POST uri ~headers ~body in
65
+ let res = Cohttp_eio.Client. call client ~sw `POST uri ~headers ~body in
75
66
read D.Response. eval_result res
76
67
77
- let get_history (c : Config.t ) cl ~sw =
68
+ let get_history (c : Config.t ) ~ client ~sw =
78
69
let uri = build_uri c " /history" in
79
70
let headers = default_headers c |> Cohttp.Header. of_list in
80
- let resp, body = Cohttp_eio.Client. get cl ~sw uri ~headers in
71
+ let resp, body = Cohttp_eio.Client. get client ~sw uri ~headers in
81
72
82
73
Logs. debug (fun k -> k " %s" (body |> Eio.Flow. read_all));
83
74
read Decoders_yojson.Basic.Decode. string (resp, body)
84
75
85
- let get_status (c : Config.t ) cl ~sw =
76
+ let get_status (c : Config.t ) ~ client ~sw =
86
77
let uri = build_uri c " /status" in
87
78
let headers = default_headers c |> Cohttp.Header. of_list in
88
- let resp, body = Cohttp_eio.Client. get cl ~sw uri ~headers in
79
+ let resp, body = Cohttp_eio.Client. get client ~sw uri ~headers in
89
80
(* Logs.debug (fun k -> k "%s" (body |> Eio.Flow.read_all)); *)
90
81
read Decoders_yojson.Basic.Decode. string (resp, body)
91
82
92
- let reset (c : Config.t ) cl ~sw =
83
+ let instance_by_name (c : Config.t ) req ~client ~sw =
84
+ let uri = build_uri c " /instance/by-name" in
85
+ let headers = default_headers c |> Cohttp.Header. of_list in
86
+ let body = make_body E.Request. instance_req_name req in
87
+ let res = Cohttp_eio.Client. call client ~sw `POST uri ~headers ~body in
88
+ read D.Response. instance_result res
89
+
90
+ let instance_by_src (c : Config.t ) req ~client ~sw =
91
+ let uri = build_uri c " /instance/by-src" in
92
+ let headers = default_headers c |> Cohttp.Header. of_list in
93
+ let body = make_body E.Request. instance_req_src req in
94
+ let res = Cohttp_eio.Client. call client ~sw `POST uri ~headers ~body in
95
+ read D.Response. instance_result res
96
+
97
+ let reset (c : Config.t ) ~client ~sw =
93
98
let uri = build_uri c " /reset" in
94
99
let headers = default_headers c |> Cohttp.Header. of_list in
95
- let res = Cohttp_eio.Client. call cl ~sw `POST uri ~headers in
100
+ let res = Cohttp_eio.Client. call client ~sw `POST uri ~headers in
96
101
read D.Response. reset_result res
102
+
103
+ let shutdown (c : Config.t ) ~client ~sw =
104
+ let uri = build_uri c " /shutdown" in
105
+ let headers = default_headers c |> Cohttp.Header. of_list in
106
+ let res = Cohttp_eio.Client. call client ~sw `POST uri ~headers in
107
+ read Decoders_yojson.Basic.Decode. string res
108
+
109
+ let verify_by_name (c : Config.t ) req ~client ~sw =
110
+ let uri = build_uri c " /verify/by-name" in
111
+ let headers = default_headers c |> Cohttp.Header. of_list in
112
+ let body = make_body E.Request. verify_req_name req in
113
+ let res = Cohttp_eio.Client. call client ~sw `POST uri ~headers ~body in
114
+ read D.Response. verify_result res
115
+
116
+ let verify_by_src (c : Config.t ) req ~client ~sw =
117
+ let uri = build_uri c " /verify/by-src" in
118
+ let headers = default_headers c |> Cohttp.Header. of_list in
119
+ let body = make_body E.Request. verify_req_src req in
120
+ let res = Cohttp_eio.Client. call client ~sw `POST uri ~headers ~body in
121
+ read D.Response. verify_result res
122
+
123
+ let decompose (c : Config.t ) req ~client ~sw =
124
+ let uri = build_uri c " /decompose" in
125
+ let headers = default_headers c |> Cohttp.Header. of_list in
126
+ let body = make_body E.Request. decomp_req_src req in
127
+ let res = Cohttp_eio.Client. call client ~sw `POST uri ~headers ~body in
128
+ read D.Response. decompose_result res
0 commit comments