2 ms·
A pretty straightforward solution is to have all your extensible options, etc., but also provide a few static objects with all options set to a working default.
by piaste 10y ago
A pretty straightforward solution is to have all your extensible options, etc., but also provide a few static objects with all options set to a working default. Use those objects for the hello world, or change the options you need to change and ONLY those options - no boilerplate.
Suave.io [0] does this very well I think. The hello world is:
open Suave
startWebServer defaultConfig (Successful.OK "Hello World!")
and as you write your application you can edit the configuration and routes as you go:
open Suave
let myConfig = { defaultConfig with logger = myCustomLogger
homeFolder = HOME_PATH }
let myRoutes = choose [ path "/helloWorld" (Successful.OK "Hello World!")
pathScan "/hello/%s" (Successful.OK << CreateCustomGreeting) ]
startWebServer myConfig myRoutes
[0] http://www.suave.io http://www.suave.io