package resto-cohttp-server

  1. Overview
  2. Docs

Serving a directory of registered services.

type callback = Cohttp_lwt_unix.Server.conn -> Cohttp.Request.t -> Cohttp_lwt.Body.t -> Cohttp_lwt_unix.Server.response_action Lwt.t

A callback passed to Cohttp_lwt_unix.Server.make_response_action. This type is used to define the middleware type.

type middleware = {
  1. transform_callback : callback -> callback;
}

A middleware function that wraps the operation of the Cohttp server that Resto builds, adding pieces of extra functionality on top of it at a low level when they cannot be implemented within the public Resto API.

We define a middleware as a transformer for the request -> response callback, which lets the middleware modify the arguments passed to the callback, run it, and then postprocess the response.

To use a middleware function, pass it to Make.launch.

module type LOGGING = sig ... end
module Make (Encoding : Resto.ENCODING) (Log : LOGGING) : sig ... end
module Make_selfserver (Encoding : Resto.ENCODING) (Log : LOGGING) : sig ... end

Make_selfserver is a functor that produces only the machinery necessary for local use. Specifically, it produces the values and types needed for the Self_serving_client.

OCaml

Innovation. Community. Security.