As of a few days ago, the embedded module was merged into Suave master. Enjoy!
I'm a great fan of Suave for simple web development in F#. I highly recommend checking out the site for details, but in the mean time I'd like to share a little trick I've been using for rapid prototyping that I'm finding very useful.
The Suave.Http module contains a few helpers for serving static files from disk. Unfortunately, depending on use case and deployment strategy, relying on the location of a bunch of files on disk can be problematic.
So (open source to the rescue!) I cracked open the code and wrote a small alternative implementation that serves files from the current assembly's embedded resources. I'm finding it especially useful for single page JavaScript apps where you have a small number of resources and then a lot of end points providing api functionality.
Setting up your website looks something like this:
123456789101112131415161718192021
moduleWebsiteopenSystemopenSuave.HttpopenSuave.TypesopenEmbeddedletapp=choose[// serve the embedded index.html for "/"GET>>=url"/">>=resource"index.html"// check if the request matches the name of an embedded resource// if it does, serve it up with a reasonable cacheGET>>=browse_embedded// If it doesn't, try and trigger your api end pointsGET>>=url"/json">>==(fun_->serveJson<|makeData())GET>>=url"/carrier">>==(fun_->getCarrierCodes())// Nothing else has worked - 404NOT_FOUND"Sorry, couldn't find your page"]web_serverdefault_configapp
@ad3mar if you feel like rolling this into Suave, you can consider it licenced under what ever is most convenient. An official licence file would make me much happier using Suave in production, by the way (hint, hint).
Edit: ad3mar has pointed out in the comments that Suave is already Apache2 licensed, I just failed to find the file last time I looked.