Module Dal_node.Proxy

The Proxy module provides functionality to create a proxy server that can intercept and mock responses for DAL node requests.

type proxy

A proxy instance.

type answer = [
  1. | `Response of string
]

Represents a possible response from a proxy route.

type route

A route definition.

val route : path:Re.Str.regexp -> callback: (path:string -> fetch_answer:(unit -> Ezjsonm.t Lwt.t) -> answer option Lwt.t) -> route

Creates a route for the proxy, containing a path pattern and a callback. The callback is provided with the path actually matched together with a fetch_answer callback to retrieve the DAL node answer for the given path. The path could be used when one wants to retreive path arguments. The fetch_answer callback could be used when one only want to modify a field in the honest response.

val make : name:string -> routes:route list -> proxy

Creates a new proxy instance.

val run : proxy -> honest_dal_node:t -> faulty_dal_node:t -> unit

Starts running the proxy server.

val stop : proxy -> unit

Stops the proxy server.