 
 (defn match-route 
   "Match a path against a parsed route. Returns a map of keywords and their
-   matching path values."
+  matching path values."
   [[regex symbols] path]
   (let [matcher (re-matcher regex path)]
     (if (. matcher (matches))

      (doseq c change
        (update-response! response c))))

(def *resources* {})

(defn add-resource
  "Add a resource to the global *resources* map. A resource is a HTTP
   method keyword, a route, and a body to be evaluated in order to generate
   a response.
   e.g. (add-resource :GET \"/welcome/:name\"
          '(str \"Hello \" (path :name)))"
  [method route & body]
  (def *resources*
    (assoc *resources* method
      (cons [(parse-route route) body]
        (*resources* method)))))

(defn find-resource
  "Find the first resource that matches the HttpServletRequest"
  [#^HttpServletRequest request]
  (let [method    (. request (getMethod))
        path      (. request (getPathInfo))
        resources (*resources* (keyword method))
        matches?  (fn [[route body]]
                    (if (match-route route path) body))]
    (some matches? resources)))

     * FixNum        - updates status code
     * map           - updates headers
     * string or seq - updates body
  Additionally, multiple updates can be chained through a vector.

  e.g (update-response! \"Foo\")       ; write 'Foo' to response body
      (update-response! [200 \"Bar\"]) ; set status to 200, and write 'Bar'"
  [#^HttpServletResponse response change]
  (cond 
    (string? change)
