Skip to content

Commit

Permalink
chore(examples): use ctx value in docker_lwt
Browse files Browse the repository at this point in the history
ps-id: 1DE4EDCB-06CC-4035-AA01-7F60B8FFF92A
  • Loading branch information
bikallem authored and rgrinberg committed May 2, 2022
1 parent 55bcbf2 commit 0a586d7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions examples/lwt_unix_doc/docker_lwt.ml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
open Lwt.Infix
open Cohttp_lwt_unix

let ctx =
let resolver =
let h = Hashtbl.create 1 in
Hashtbl.add h "docker" (`Unix_domain_socket "/var/run/docker.sock");
Resolver_lwt_unix.static h
in
Cohttp_lwt_unix.Client.custom_ctx ~resolver ()

let t =
Client.get (Uri.of_string "http://docker/version") >>= fun (resp, body) ->
Cohttp_lwt_unix.Client.get ~ctx (Uri.of_string "http://docker/version")
>>= fun (resp, body) ->
let open Cohttp in
let code = resp |> Response.status |> Code.code_of_status in
Printf.printf "Response code: %d\n" code;
Expand Down

0 comments on commit 0a586d7

Please sign in to comment.