package paf

  1. Overview
  2. Docs

Parameters

Signature

type stack = Stack.TCP.t

The type of the TCP/IP stack.

module TCP : sig ... end
module TLS : sig ... end
type t

The type of the socket bound on a specific port (via init).

type dst = Ipaddr.t * int
val init : port:int -> stack -> t Lwt.t

init ~port stack bounds the given stack to a specific port and return the main socket t.

val accept : t -> (TCP.flow, [> `Closed ]) result Lwt.t

accept t waits an incoming connection and return a socket connected to a peer.

val close : t -> unit Lwt.t

close t closes the main socket.

http_service ~error_handler request_handler makes an HTTP/AF service where any HTTP/1.1 requests are handled by request_handler. The returned service is not yet launched (see serve).

https_service ~tls ~error_handler request_handler makes an HTTP/AF service over TLS (from the given TLS configuration). Then, HTTP/1.1 requests are handled by request_handler. The returned service is not yet launched (see serve).

val serve : ?stop:Lwt_switch.t -> 't Paf.service -> 't -> [ `Initialized of unit Lwt.t ]

serve ?stop service returns an initialized promise of the given service service. stop can be used to stop the service.

val tcp_protocol : (stack * Ipaddr.t * int, TCP.flow) Mimic.protocol
val tcp_edn : (stack * Ipaddr.t * int) Mimic.value
val tls_edn : ([ `host ] Domain_name.t option * Tls.Config.client * stack * Ipaddr.t * int) Mimic.value
val tls_protocol : ([ `host ] Domain_name.t option * Tls.Config.client * stack * Ipaddr.t * int, TLS.flow) Mimic.protocol
val run : ctx:Mimic.ctx -> error_handler:(dst option -> Alpn.client_error -> unit) -> response_handler:(dst option -> Alpn.response -> Alpn.body -> unit) -> [ `V1 of Httpaf.Request.t | `V2 of H2.Request.t ] -> (Alpn.body, [> Mimic.error ]) result Lwt.t