1- // open Lwt
2- // open Cohttp
3- // open Cohttp_lwt_unix
4- // TODO use above mentioned packages for http client to call goblint http server
1+ open Lwt
2+ open Cohttp
3+ open Cohttp_lwt
54
5+ module Client = Cohttp_lwt_jsoo . Client
66module ReactDOM = React . Dom
77
88type paramState = Executed | Executing | Canceled | Error ;
@@ -18,17 +18,31 @@ let make = (~parameters, ~history, ~setHistory) => {
1818 }, [| value|] );
1919
2020 let on_change = (new_value) => {
21- setValue(_ => new_value)
21+ setValue(_ => new_value);
2222 };
2323
2424 let on_submit = () => {
2525 let newHistory = Array . append(history, [| (value, Time . getLocalTime() , Executing )|] )
26- setHistory(_ => newHistory)
27-
28- // TODO transform param string with "' '" seperation mask
29- // TODO execute newly transformed params
26+ setHistory(_ => newHistory);
3027
31- // TODO use cohttp to call goblint server
28+ let /* parameterList*/ _ = ParameterUtils . constructParameters(value);
29+ let headers = Header . init_with("Content-Type" , "application/json" );
30+ let body = "{
31+ \" jsonrpc\" : \" 2.0\" ,
32+ \" id\" : \" 5\" ,
33+ \" method\" : \" analyze\" ,
34+ \" params\" : {\" reset\" : false}
35+ }"
36+ |> Body . of_string;
37+ let url = "127.0.0.1:8001" |> Uri . of_string;
38+
39+ let _ = Client . put(url, ~body= body, ~headers= headers) >>= ((res, _ /* body*/ )) => {
40+ res |> Response . status |> Code . code_of_status |> string_of_int |> Util . log;
41+ /* body |> Body.to_string >|= (b) => {
42+ Util.log(b);
43+ };*/
44+ Lwt . return () ;
45+ };
3246
3347 setDisableCancel(_ => false );
3448 };
0 commit comments