chickadee » phricken » handle-file

handle-file rootprocedure

Returns a file handler for the document root at ROOT. The filename path will be taken from the request's second submatch and so is generally wrapped in a match-resource.

This handler sends every file via gopher#send-binary-file, even type 0 text files. This seems to be okay with modern (ahem) Gopher clients, which are less stringent about a terminating full-stop and don't require lines end in CRLF. Clients therefore receive a verbatim representation of the text file instead of a transformed one, as you would over the web. If you wish to treat text files separately, you might define a similar handler which uses extension-type to distinguish between text and binary files.

(match-resource "/pub/www" (handle-file "/var/www/myhost/pub"))
; Now selector /pub/www/todo.txt sends /var/www/myhost/pub/todo.txt