Module Naboris.ServerConfig
Module for configuring the naboris http server.
type 'sessionData ttype httpAfConfig={read_buffer_size : int;request_body_buffer_size : int;response_buffer_size : int;response_body_buffer_size : int;}
val create : unit -> 'sessionData tReturns default config. Used as the starting place to build the config.
val setOnListen : (unit -> unit) -> 'sessionData t -> 'sessionData tCreate new config from
t('sessionData)with the onListen functionunit => unit.onListenfunction 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 tCreates new config from
t('sessionData)with mapSession functionoption(string) => Lwt.t(option(Session.t('sessionData))).mapSessionfunction is called at the very beginning of each request/response lifecycle. Used to set session data into theReq.t('sessionData)for use later in the request/response lifecycle.~maxAgeOptional param to set max age for session cookies in seconds (defaults to 30 days)~sidKeyOptional 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 tCreates new config from
t('sessionData)with requestHandler(Route.t, Req.t('sessionData), Res.t) => Lwt.t(Res.t).requestHandleris the main handler function for responding to incoming http requests.
val setErrorHandler : ErrorHandler.t -> 'sessionData t -> 'sessionData tCreates new config from
t('sessionData)with errorHandlerErrorHandler.t.This configuration is optional and by default
Res.reportErrorwill respond with500and the text of theexnprovided.
val setHttpAfConfig : httpAfConfig -> 'sessionData t -> 'sessionData tCreates new config from
t('sessionData)with httpAfConfighttpAfConfig.
val addMiddleware : 'sessionData Middleware.t -> 'sessionData t -> 'sessionData tCreates nwe config from
t('sessionData)with the added middlewareMiddleware.t('sessionData).Middlewares are executed in the order they are added. The final "middleware" is the
requestHandler.
val addStaticMiddleware : string list -> string -> 'sessionData t -> 'sessionData tCreates a virtual path prefix
list(string)and maps it to a local directorystring.Middlewares are executed in the order they are added. The final "middleware" is the
requestHandler.
val sessionConfig : 'sessionData t -> 'sessionData SessionConfig.t optionReturns
SessionConfig.t('sessionData)from config.Noneif none is configured.
val middlewares : 'sessionData t -> 'sessionData Middleware.t listReturns list of middlewares from the config.
val onListen : 'sessionData t -> unit -> unitReturns
onListenfunction oft.
val routeRequest : 'sessionData t -> Route.t -> 'sessionData Req.t -> Res.t -> Res.t Lwt.tReturns
routeRequestfunction oft.
val errorHandler : 'sessionData t -> ErrorHandler.t optionReturns
option(ErrorHandler.t)oft.
val httpAfConfig : 'sessionData t -> Httpaf.Config.t optionReturns
option(HttpAf.Config.t)oft.