package tiny_httpd

  1. Overview
  2. Docs

Middlewares

A middleware can be inserted in a handler to modify or observe its behavior.

  • since 0.11
type handler = byte_stream Request.t -> resp:(Response.t -> unit) -> unit

Handlers are functions returning a response to a request. The response can be delayed, hence the use of a continuation as the resp parameter.

type t = handler -> handler

A middleware is a handler transformation.

It takes the existing handler h, and returns a new one which, given a query, modify it or log it before passing it to h, or fail. It can also log or modify or drop the response.

val nil : t

Trivial middleware that does nothing.

OCaml

Innovation. Community. Security.