Hi Ricardo! On 9/4/20 6:44 PM, Ricardo Wurmus wrote: > Zelphir Kaltstahl <[email protected]> writes: > >> So I have a few questions: >> >> (1) How do you do your Guile web development? What's the setup? > I don’t use a framework in my web projects; just the included web > modules and sometimes the fibers web server. I keep everything > stateless so that I can spin up many workers (i.e. Guile processes > with a web server listening on one of a range of local ports) and > dispatch to them from a reverse proxy such as Nginx or Lighttpd. > >> (2) What do you use to serve static files (securely)? If you use Guile's >> web server, how exactly do you do it? Do you have the code somewhere? > I configure an assets directory and define a procedure that sanitizes > the requested file name to serve it from that directory. I don’t do > much with files so I don’t usually do anything other than > > (call-with-input-file file-name get-bytevector-all) > > for the body of the response. But if I had to send large files I’d use > “sendfile” directly.
Don't you need to also check what kind of file type it is and select the appropriate MIME type for answering the request? (Do you have some code public somewhere, showing how to do this?) And how do you use sendfile directly? (Code example for this would also be great to see.) (I've checked https://github.com/rekado and https://git.elephly.net/, but could not find a web server project.) Is it still necessary to sanitize the requested file names, when an HTTP server handles requests for assets before the Guile application is hit? >> (3) Perhaps there is a minimalistic option instead of NGINX or HAProxy >> out there, which is also free software? Is there perhaps even anything >> in Guile, which I could use, that is suitable for serving static files? > Lighttpd seems to be lighter than Nginx. If all you want is serve > static files upon request I’d use just Guile, matching on the request, > looking up the file in a declared directory, and using sendfile to push > it to the requester. Best regards, Zelphir
