[ANN] Opium 0.19.0

According the interface of opium, it’s possible to have the support of TLS (with ocaml-tls) with the new version of Conduit and paf (which is a MirageOS compatible layer of HTTP/AF - unreleased):

let stack ip =
  Tcpip_stack_socket.UDPV4.connect (Some ip) >>= fun udpv4 ->
  Tcpip_stack_socket.TCPV4.connect (Some ip) >>= fun tcpv4 ->
  Tcpip_stack_socket.connect [ ip ] udpv4 tcpv4

let http_with_conduit (ip, port) error_handler request_handler =
  Paf.https httpaf_config ~error_handler ~request_handler:(fun _ -> request_handler)
    ({ Paf.TCP.stack= stack ip
     ; keepalive= None
     ; nodelay= false
     ; port= port}, Tls.Config.server ~certificates ())

let () = match Lwt_main.run (Opium.run (https_with_conduit (Ipaddr.V4.localhost, 4343)) opium_app) with
  | Ok () -> ()
  | Error err -> Fmt.epr "%a.\n%!" Conduit_mirage.pp_error err

I used it for a long time on my personal unikernels and did some tests to ensure that it does not fails when it handles many requests. Note that you are able to use OpenSSL too if you want.

5 Likes