Skip to content

Commit

Permalink
feat: printing body
Browse files Browse the repository at this point in the history
  • Loading branch information
aidmandorky committed Feb 21, 2024
1 parent 7e165c7 commit 82dbcfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/test_eio.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let () =

let response http ~sw =
Log.debug (fun k -> k "Sending query to server...");
let result = Main_eio.reset config http ~sw in
let result = Main_eio.get_history config http ~sw in
match result with
| Ok st ->
Log.app (fun k ->
Expand Down
11 changes: 7 additions & 4 deletions src/main_eio.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ let read (dec : 'a Decoders_yojson.Basic.Decode.decoder)
let get_history (c : Config.t) cl ~sw =
let uri = build_uri c "/history" in
let headers = default_headers c |> Cohttp.Header.of_list in
let res = Cohttp_eio.Client.get cl ~sw uri ~headers in
read Decoders_yojson.Basic.Decode.string res
let resp, body = Cohttp_eio.Client.get cl ~sw uri ~headers in
Logs.app (fun k -> k "%s" (body |> Eio.Flow.read_all));

read Decoders_yojson.Basic.Decode.string (resp, body)

let get_status (c : Config.t) cl ~sw =
let uri = build_uri c "/status" in
let headers = default_headers c |> Cohttp.Header.of_list in
let res = Cohttp_eio.Client.get cl ~sw uri ~headers in
read Decoders_yojson.Basic.Decode.string res
let resp, body = Cohttp_eio.Client.get cl ~sw uri ~headers in
Logs.app (fun k -> k "%s" (body |> Eio.Flow.read_all));
read Decoders_yojson.Basic.Decode.string (resp, body)

let reset (c : Config.t) cl ~sw =
let uri = build_uri c "/reset" in
Expand Down

0 comments on commit 82dbcfe

Please sign in to comment.