Server Configuration

There are a number of helper functions for building server config records.

# Creating a Server Config

ServerConfig.create is used to generate a default server config object, this will be the starting point.

1// ReasonML
2let create: unit => ServerConfig.t('sessionData);
1(* OCaml *)
2val create: unit -> 'sessionData ServerConfig.t

# Listen Callback

ServerConfig.setOnListen will set the function that will be called once the server has started and is listening for connections. The onListen function has the type signature unit => unit.

1// ReasonML
2let setOnListen: (unit => unit, ServerConfig.t('sessionData)) => ServerConfig.t('sessionData)
1(* OCaml *)
2val setOnListen: (unit -> unit) -> 'sessionData ServerConfig.t -> 'sessionData ServerConfig.t

# Request Handler

ServerConfig.setRequestHandler will set the main request handler function on the config. This function is the main entry point for http requests and usually where routing the request happens. The requestHandler function has the type signature (Route.t, Req.t('sessionData), Res.t) => Lwt.t(Res.t).

1// ReasonML
2let setRequestHandler: (
3  (Route.t, Req.t('sessionData), Res.t) => Lwt.t(Res.t),
4  ServerConfig.t('sessionData)
5) => ServerConfig.t('sessionData)
1(* OCaml *)
2val setRequestHandler: (Route.t -> 'sessionData Req.t -> Res.t -> Res.t Lwt.t)
3  -> 'sessionData ServerConfig.t -> 'sessionData ServerConfig.t
Support us on GitHub

Star, follow, fork

Star Fork

Found a typo? a bug? or something that just doesn't make any sense? Help improve these docs by opening a github issue.

naboris source code is licensed MIT.
It can be used, copied, and modified free of charge. However, the software is provided "as is" without any warranties. Click the link above for more information.