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 ->
(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"
)
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
.
val sessionConfig : 'sessionData t -> 'sessionData SessionConfig.t option
Returns SessionConfig.t('sessionData)
from config. None
if none is configured.
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
.