Arc Forumnew | comments | leaders | submitlogin
srv update to handle files
6 points by byronsalty 6123 days ago | discuss
I just added general file serving support to srv.arc (in git repo) so now you should be able to serve your whole app with srv instead of relying on a different webserver to host your static files. Again you probably only want to do this while developing but the support is there to do otherwise.

The basics: I changed the (respond) function to first check if a file exists and if so stream that back (previously it would try to stream back any path that ended with .gif only, without a file check). Part of this was a simple couple of functions which extract the extension and the lookup the mime type based on that, if none is found assume text.

I also added an additional level of error catching which is designed to detect errors (presumably in ops) and now return a 500, as well as the message associated. Unfortunately, the 200 headers are committed before any op is process so currently you'll get the 200 header, followed by a 500 header. Need to figure out how to prevent that nicely.

Other things that need to be done now: - create some mechanism to prevent simply any file from being returned. Probably this will end up as a configurable docroot property. - fix duplicate header mentioned above - allow configurable 404 and 500 pages