Module Webs.Connector

module Connector: sig .. end
Generic web server connector interface.

Connectors are not required to follow this interface. They are however encouraged to do so, to make it easier for clients to be able to use multiple connectors for their service.



Connector


type error = [ `Connector of Rresult.R.msg
| `Service of Rresult.R.exn_trap
| `Webserver of Rresult.R.msg ]
The type for connector errors. See Errors.
type conf = Webs.Dict.t 
The type for connector configuration.
type t = conf ->
Webs.service -> (unit, error) Rresult.result
The type for connectors.

A call connect c s to a connector configures the connection to the webserver c and installs the service s.

Implementation duties. The implementation of connect should satisfy the following constraints.



Standard configuration keys

Connectors can define their own keys but should favor standard ones if appropriate. See also the Webs_unix configuration keys.

val sendfile_header : string Webs.Dict.key
sendfile_header is key defining a header name.

Purpose. If a connector supports this key, file response bodies are not handled by the connector. The filename is returned to the web server in this header. Use for example "x-accel-redirect" for nginx or "x-sendfile" for Apache with mod_xsendfile and Lightppd.

val service_exn_log : Format.formatter Webs.Dict.key
error_log is a key defining a formatter to log service errors.

Purpose. If a connector supports this key, it must log uncaught service exceptions to the given formatter.


Errors


val pp_error : Format.formatter -> error -> unit
pp_error ppf e prints an unspecified representation of e on ppf.
val open_error : ('a, error) Rresult.result ->
('a, [> error ]) Rresult.result
val error_to_msg : ('a, error) Rresult.result ->
('a, Rresult.R.msg) Rresult.result