           "Content-Type" (context-mimetype context (str update))))
         (pipe-stream in out))))
 
-(def #^{:doc
-  "A global list of all registered resources. A resource is a vector
-  consisting of a HTTP method, a parsed route, function that takes in
-  a context, request and response object.
-  e.g.
-  [\"GET\"
-   (parse-route \"/welcome/:name\") 
-   (fn [context request response] ...)]"}
-  *resources* '())
+;;;; Resource ;;;;
 
 (def #^{:doc
   "A set of bindings available to each resource. This can be extended

    (if (. matcher (matches))
      (apply hash-map
        (interleave symbols (rest (re-groups matcher)))))))

(defn update-response
  "Destructively update a HttpServletResponse via a Clojure datatype.

    header   #(. request (getHeader %))
    mime     #(context-mimetype (str %))))

(defmacro resource
  "Create a pseudo-servlet from a resource. It's not quite a real
  servlet because it's a function, rather than an HttpServlet object."
  [& body]
  `(fn ~'[route context request response]
     (let ~(apply vector *resource-bindings*)
       (update-response ~'response ~'context (do ~@body)))))

(def *default-resource*
  (resource
    (let [static-file (file "public" full-path)]
      (if (. static-file (isFile))
        static-file
        [404 "Cannot find file"]))))
