awwx.ws

srv-staticdirs

Multiple static dirs

--- a/srv.arc	2009-12-01 20:20:49.000000000 -0500
+++ b/srv.arc	2009-12-01 20:41:21.000000000 -0500
@@ -2,7 +2,7 @@
 
 ; To improve performance with static files, set static-max-age*.
 
-(= arcdir* "arc/" logdir* "arc/logs/" staticdir* "static/")
+(= arcdir* "arc/" logdir* "arc/logs/" staticdirs* '("static/"))
 
 (= quitsrv* nil breaksrv* nil) 
 
@@ -23,7 +23,7 @@
   (w/socket s port (handle-request s t)))
 
 (def ensure-srvdirs ()
-  (map ensure-dir (list arcdir* logdir* staticdir*)))
+  (map ensure-dir (+ (list arcdir* logdir*) staticdirs*)))
 
 (= srv-noisy* nil)
 
@@ -226,7 +226,7 @@
                      (prn "Cache-Control: max-age=" it))
                    (f req!str req)))
          (let filetype (static-filetype req!op)
-           (aif (and filetype (file-exists (string staticdir* req!op)))
+           (aif (and filetype (some [file-exists (string _ req!op)] staticdirs*))
                 (do (prn (type-header* filetype))
                     (awhen static-max-age*
                       (prn "Cache-Control: max-age=" it))

Bugs

Get this hack

hack ycombinator.com/arc/arc3.1.tar \
  awwx.ws/ac0.hack \
  awwx.ws/srv-misc0.patch \
  awwx.ws/srv-staticdirs0.patch

unLicense

This patch is in the public domain. The combination of this patch and Arc may be redistributed or modified under the same terms as Arc itself.

Contact me

Twitter: awwx
Email: andrew.wilcox [at] gmail.com