Skip to content

Commit

Permalink
Added syntax for defining custom regex matchers in routes
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Dec 1, 2009
1 parent 9f8aa96 commit 41cf21e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/compojure/routes.clj
Expand Up @@ -29,12 +29,15 @@
"Compiles a function to match a HTTP request against the supplied method
and route."
[method route]
(let [matcher (if (string? route)
(route-compile route)
route)]
(let [matcher (cond
(string? route) (route-compile route)
(seq? route) (route-compile
(first route)
(apply hash-map (rest route)))
:otherwise route)]
`(fn [request#]
(and (method-matches ~method request#)
(route-matches ~route request#)))))
(route-matches ~matcher request#)))))

(defmacro with-request-bindings
"Add shortcut bindings for the keys in a request map."
Expand Down

0 comments on commit 41cf21e

Please sign in to comment.