package ohttp-piaf

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

Module Ohttp_piafSource

Oblivious HTTP over Piaf.

The client, relay, and gateway of Ohttp.Service, as calls and server handlers of Piaf, over HTTP/1.1 or HTTP/2.

Eio_main.run @@ fun env ->
Eio.Switch.run @@ fun sw ->
(* A gateway for one target. Build each handler once: the requests in flight
   are counted in [service]. *)
let gateway =
  Ohttp_piaf.Gateway.handler service
    (Ohttp_piaf.Target.forward env
       ~targets:[ ("example.com", Uri.of_string "http://127.0.0.1:8000") ])
in
let config =
  Piaf.Server.Config.create (`Tcp (Eio.Net.Ipaddr.V4.any, 8080))
in
ignore
  (Piaf.Server.Command.start ~sw env (Piaf.Server.create ~config gateway))

Contents are read in full: an encapsulated message is only opened when it is complete. Each read is limited (see Ohttp.Service.default_max_request_size and Ohttp.Service.default_max_response_size): what is longer is refused as soon as its declared length or what has arrived of it passes the limit, and the rest of it is read without being kept, since Piaf is done with a message only once its body has been read. Every request that the client, the relay, or the forwarding to a target makes is a Piaf.Client.Oneshot request, in a switch of its own that it leaves when the response has been read.

Sourcetype 'ctx handler = 'ctx Piaf.Server.ctx -> Piaf.Response.t

A handler of a Piaf server, for any context: Piaf.Server.create ~config handler.

How a gateway gets a response for a request that it has decapsulated: from a target, with Target.forward, or in any other way.

Sourcetype error = [
  1. | `Ohttp of Ohttp.Error.t
  2. | `Piaf of Piaf.Error.t
]

A client's failure: of the protocol, or of the transport.

Sourceval pp_error : Format.formatter -> error -> unit
Sourcemodule Gateway : sig ... end

A gateway: its key configurations, and the resource to which relays send Encapsulated Requests.

Sourcemodule Client : sig ... end

A client: fetches key configurations, and sends requests through a relay.

Sourcemodule Relay : sig ... end

A relay, which forwards to one gateway.

Sourcemodule Target : sig ... end

Targets that the gateway reaches over HTTP.