From 82dbcfe9a0ac819f7138ca38c0601c8a59b199bf Mon Sep 17 00:00:00 2001 From: Koundinya Vajjha Date: Wed, 21 Feb 2024 14:40:23 -0800 Subject: [PATCH] feat: printing body --- bin/test_eio.ml | 2 +- src/main_eio.ml | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/test_eio.ml b/bin/test_eio.ml index 68ff258..cbd4efd 100644 --- a/bin/test_eio.ml +++ b/bin/test_eio.ml @@ -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 -> diff --git a/src/main_eio.ml b/src/main_eio.ml index 14277c5..665bdf1 100644 --- a/src/main_eio.ml +++ b/src/main_eio.ml @@ -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