   ([]         (page-not-found "public/404.html"))
   ([filename] [404 (file filename)]))
  
+(defn- find-index-file
+  "Search the directory for index.*"
+  [dir]
+  (first
+    (filter
+     #(re-matches #"index\\..*" (.toLowerCase (.getName %)))
+      (.listFiles dir))))
+
 (defn serve-file
-  "Attempts to serve up a static file from a directory. Nil is returned if the
-  file does not exist."
+  "Attempts to serve up a static file from a directory, which defaults to
+  './public'. Nil is returned if the file does not exist. If the file is a
+  directory, the function looks for a file in the directory called 'index.*'."
   ([path]
     (serve-file "public" path))
   ([root path]
-    (let [static-file (file root path)]
-      (if (.isFile static-file)
-        static-file))))
+    (let [filepath (file root path)]
+      (cond
+        (.isFile filepath)
+          filepath
+        (.isDirectory filepath)
+          (find-index-file filepath)))))
  
 ;;;; Servlet creation ;;;;
  

;; HTTP handler library for Compojure
(ns compojure.http
  (:use (compojure control
                   file-utils

                          response))))
 
(defmacro defservlet
  "Shortcut for (def name doc? (servlet handlers))"
  [name doc & handlers]
  (if (string? doc)
    `(def
