After starting some work on this it'll require a few changes, but the overall API I'm looking forward to is:
module Httpkit = Httpkit.Make(Httpkit_lwt_unix_h2);
/* module Httpkit = Httpkit.Make(Httpkit_lwt_mirage_h2); */
/* module Httpkit = Httpkit.Make(Httpkit_lwt_unix_httpaf); */
/* Server side*/
Httpkit.Server.(
make(App.initial_state)
|> use(Common.log)
|> use(App.inc)
|> reply(App.json)
|> Httpkit.Server.Http.listen(~port=9999, ~on_start)
/*|> Httpkit.Server.Https.TLS.listen(~port=9999, ~on_start, ~key, ~cert) */
/*|> Httpkit.Server.Https.SSL.listen(~port=9999, ~on_start, ~key, ~cert) */
|> Lwt_main.run
);
/* Client side */
let req =
Httpkit.Client.Request.create(
~headers=[("User-Agent", "Reason HttpKit")],
`GET,
Uri.of_string("http://api.github.com/repos/ostera/httpkit"),
);
Httpkit.Client.(
req
|> Http.send
/*|> Https.TLS.send(~config=Https.Config.from_pems(~cert, ~priv_key)) */
/*|> Https.SSL.send(~config=Https.Config.from_pems(~cert, ~priv_key)) */
>>= Response.body
|> Lwt_main.run
);
After starting some work on this it'll require a few changes, but the overall API I'm looking forward to is: