fix example

This commit is contained in:
Simon Cruanes 2023-08-08 15:21:22 -04:00
parent 572168967f
commit b7eb8f56a0
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -4,10 +4,10 @@ let serve_zeroes server : unit =
H.add_route_handler server H.(Route.(exact "zeroes" @/ int @/ return))
@@ fun n _req ->
(* stream [n] zeroes *)
let write (oc : H.IO.Out_channel.t) : unit =
let write (oc : H.IO.Output.t) : unit =
let buf = Bytes.make 1 '0' in
for _i = 1 to n do
H.IO.Out_channel.output oc buf 0 1
H.IO.Output.output oc buf 0 1
done
in
let writer = H.IO.Writer.make ~write () in
@ -24,7 +24,7 @@ let serve_file server : unit =
Fun.protect ~finally:(fun () -> close_in_noerr ic) @@ fun () ->
while
let n = input ic buf 0 (Bytes.length buf) in
if n > 0 then H.IO.Out_channel.output oc buf 0 n;
if n > 0 then H.IO.Output.output oc buf 0 n;
n > 0
do
()