httpkit
httpkit copied to clipboard
HTTP2 Support
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
);
I think you don't want to think about if it's http1 or http2 in most cases. If you need special functionality like streaming in either the client or server maybe you should specify that explicitly.
If possible module Httpkit = Httpkit.Make(Httpkit_lwt_unix_h2); shouldn't be seen by the consumer of Httpkit in that case.