package mehari-lwt-unix

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file mehari_lwt_unix.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
open Lwt.Syntax
include Mehari_io

let response_document = File.respond_document
let static = File.static
let run_cgi = File.run_cgi

let stack ~v4 ~v6 =
  let* tcp =
    Stack.TCP.connect
      ~ipv4_only:(match v6 with None -> true | _ -> false)
      ~ipv6_only:false v4 v6
  in
  let* udp =
    Stack.UDP.connect
      ~ipv4_only:(match v6 with None -> true | _ -> false)
      ~ipv6_only:false v4 v6
  in
  Stack.connect udp tcp

let default_ipv4 = Ipaddr.V4.Prefix.make 8 Ipaddr.V4.localhost

let run_lwt ?port ?verify_url_host ?config ?timeout ~certchains
    ?(v4 = default_ipv4) ?v6 callback =
  Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
  let* stack = stack ~v4 ~v6 in
  run ?port ?timeout ?verify_url_host ?config ~certchains stack callback

let run ?port ?verify_url_host ?config ?timeout ~certchains ?v4 ?v6 callback =
  run_lwt ?port ?timeout ?verify_url_host ?config ~certchains ?v4 ?v6 callback
  |> Lwt_main.run
OCaml

Innovation. Community. Security.