1- open Lwt
2- open Cohttp
3- open Cohttp_lwt
1+ open Lwt ;
2+ open Cohttp ;
3+ open Cohttp_lwt ;
44
5- module Js = Js_of_ocaml . Js
6- module Client = Cohttp_lwt_jsoo . Client
7- module ReactDOM = React . Dom
5+ module Js = Js_of_ocaml . Js ;
6+ module Client = Cohttp_lwt_jsoo . Client ;
7+ module ReactDOM = React . Dom ;
88
99type paramState = Executed | Executing | Canceled | Error ;
1010
@@ -188,19 +188,20 @@ let make = (~goblint_path, ~inputValue, ~setInputValue, ~disableRun, ~setDisable
188188 }
189189 }
190190
191+ let transform_resp = ((res, body)) => {
192+ let code = res |> Response . status |> Code . code_of_status;
193+
194+ Cohttp_lwt . Body . to_string(body) >>= (body) => {
195+ if (code < 200 || code >= 400 ) {
196+ Lwt . return((Error , body));
197+ } else {
198+ Lwt . return((Executed , body));
199+ };
200+ }
201+ };
202+
191203 let inner_config_api_call = (config_body): Lwt . t((paramState, string)) => {
192- Client . post(config_uri, ~body= config_body, ~headers= headers) >>=
193- ((res, body)) => {
194- let code = res |> Response . status |> Code . code_of_status;
195-
196- Cohttp_lwt . Body . to_string(body) >>= (body) => {
197- if (code < 200 || code >= 400 ) {
198- Lwt . return((Error , body));
199- } else {
200- Lwt . return((Executed , body));
201- };
202- }
203- };
204+ Client . post(config_uri, ~body= config_body, ~headers= headers) >>= transform_resp
204205 };
205206
206207 let config_api_call = (config_opts: list ((string , string ))) => {
@@ -221,7 +222,7 @@ let make = (~goblint_path, ~inputValue, ~setInputValue, ~disableRun, ~setDisable
221222 |> Body . of_string;
222223 })
223224 |> List . map(inner_config_api_call)
224- |> Lwt . npick ;
225+ |> Lwt . all ;
225226 };
226227
227228 let exception_handler = (exc) => {
@@ -232,18 +233,7 @@ let make = (~goblint_path, ~inputValue, ~setInputValue, ~disableRun, ~setDisable
232233 };
233234
234235 let inner_analyze_api_call = (analyze_body) => {
235- Client . post(analyze_uri, ~body= analyze_body, ~headers= headers) >>=
236- ((res, body)) => {
237- let code = res |> Response . status |> Code . code_of_status;
238-
239- Cohttp_lwt . Body . to_string(body) >>= (body) => {
240- if (code < 200 || code >= 400 ) {
241- Lwt . return((Error , body));
242- } else {
243- Lwt . return((Executed , body));
244- };
245- }
246- };
236+ Client . post(analyze_uri, ~body= analyze_body, ~headers= headers) >>= transform_resp
247237 };
248238
249239 let analyze_body =
0 commit comments