Skip to content

Commit bfc4a07

Browse files
committed
Fix config endpoint call to respond correctly
1 parent 314bc56 commit bfc4a07

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

src/ui/panel/ParameterView.re

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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

99
type 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 =

src/utils/ParameterUtils.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open State
1+
open State;
22

33
let concat_parameter_list = String.concat(" ");
44
let concat_grouped_parameters = (parameters) => parameters |> List.map(concat_parameter_list) |> concat_parameter_list;

0 commit comments

Comments
 (0)