Library
Module
Module type
Parameter
Class
Class type
include Mehari.NET
with module IO := IO
and type addr = Ipaddr.t
and type clock := unit
type handler = addr Mehari.request -> Mehari.response IO.t
val no_middleware : middleware
val pipeline : middleware list -> middleware
val route :
?rate_limit:rate_limiter ->
?mw:middleware ->
?regex:bool ->
string ->
handler ->
route
val scope :
?rate_limit:rate_limiter ->
?mw:middleware ->
string ->
route list ->
route
val no_route : route
val make_rate_limit :
?period:int ->
int ->
[ `Second | `Minute | `Hour | `Day ] ->
rate_limiter
Same as Mehari.NET.make_rate_limit
but without the required trailing unit parameter.
Same as Mehari.NET.logger
but without the required trailing unit parameter.
Same as Mehari.response
, but the new Mehari.response
is wrapped in a promise.
Same as respond
but respond with given Mehari.body
and use given Mehari.mime
as mime type.
Same as respond
but respond with given text and use text/plain
as Mehari.mime
type.
val respond_gemtext :
?charset:string ->
?lang:string list ->
Mehari.Gemtext.t ->
Mehari.response IO.t
Same as respond
but respond with given Mehari.Gemtext.t
and use text/gemini
as Mehari.mime
type.
Same as Mehari.response_raw
, but the new Mehari.response
is wrapped in a promise.
val run :
?port:int ->
?verify_url_host:bool ->
?config:Tls.Config.server ->
?timeout:float ->
certchains:Tls.Config.certchain list ->
stack ->
handler ->
unit IO.t
run ?port ?verify_url_host ?config ?timeout ?certchains stack handler
runs the server using host
.
port
is the port to listen on. Defaults to 1965
.verify_url_host
, if true (by default), will verify if the URL hostname corresponds to the server's certificate (chosen according to ocaml-tls sni.md).config
is the TLS server configuration. Defaults to
Tls.Config.server ~certificates
~authenticator:(fun ?ip:_ ~host:_ _ -> Ok None)
()
To support client certificates, specify the authenticator
.
timeout
is the maximum waiting time in seconds for the client to write a request after TLS handshake. Unset by default.certchains
is the list of form [(certs, key); ...]
, the last one is considered default.