Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Module for configuring the naboris http server.
val create : unit -> 'sessionData t
Returns default config. Used as the starting place to build the config.
Create new config from t('sessionData)
with the onListen function unit => unit
.
onListen
function is called once the server is created successfully.
val setSessionConfig :
?maxAge:int ->
?sidKey:string ->
?secret:string ->
(string option -> 'sessionData Session.t option Lwt.t) ->
'sessionData t ->
'sessionData t
Creates new config from t('sessionData)
with mapSession function option(string) => Lwt.t(option(Session.t('sessionData)))
.
mapSession
function is called at the very beginning of each request/response lifecycle. Used to set session data into the Req.t('sessionData)
for use later in the request/response lifecycle.
~maxAge
Optional param to set max age for session cookies in seconds (defaults to 30 days) ~sidKey
Optional param to set key for session cookies (defaults to "nab.sid"
) ~secret
Optional param but recommended to set this to a secure string.
val setRequestHandler :
(Route.t -> 'sessionData Req.t -> Res.t -> Res.t Lwt.t) ->
'sessionData t ->
'sessionData t
Creates new config from t('sessionData)
with requestHandler (Route.t, Req.t('sessionData), Res.t) => Lwt.t(Res.t)
.
requestHandler
is the main handler function for responding to incoming http requests.
val setErrorHandler : ErrorHandler.t -> 'sessionData t -> 'sessionData t
Creates new config from t('sessionData)
with errorHandler ErrorHandler.t
.
This configuration is optional and by default Res.reportError
will respond with 500
and the text of the exn
provided.
val setHttpAfConfig : httpAfConfig -> 'sessionData t -> 'sessionData t
Creates new config from t('sessionData)
with httpAfConfig httpAfConfig
.
val addMiddleware :
'sessionData Middleware.t ->
'sessionData t ->
'sessionData t
Creates nwe config from t('sessionData)
with the added middleware Middleware.t('sessionData)
.
Middlewares are executed in the order they are added. The final "middleware" is the requestHandler
.
Creates a virtual path prefix list(string)
and maps it to a local directory string
.
Middlewares are executed in the order they are added. The final "middleware" is the requestHandler
.
Set Cache-control
header value which is returned with every request for a static file.
If None
then Cache-control
header is omitted.
val sessionConfig : 'sessionData t -> 'sessionData SessionConfig.t option
Returns SessionConfig.t('sessionData)
from config. None
if none is configured.
Set bool
flag which true
signals the server to send Last-Modified
headers with static file responses.
val staticLastModified : 'sessionData t -> bool
Returns bool
from config, which true
signals the server to send Last-Modified
headers with static file responses.
val setEtag : Etag.strength option -> 'sessionData t -> 'sessionData t
Set option([`Storng | `Weak])
which signals the server to set etags as strong or weak. None
will set no etag headers.
val etag : 'sessionData t -> Etag.strength option
Returns currently configured etag header strength.
val middlewares : 'sessionData t -> 'sessionData Middleware.t list
Returns list of middlewares from the config.
val onListen : 'sessionData t -> unit -> unit
Returns onListen
function of t
.
Returns routeRequest
function of t
.
val errorHandler : 'sessionData t -> ErrorHandler.t option
Returns option(ErrorHandler.t)
of t
.
val httpAfConfig : 'sessionData t -> Httpaf.Config.t option
Returns option(HttpAf.Config.t)
of t
.
val staticCacheControl : 'sessionData t -> string option
Returns staticCacheControl
value of t
.