Permalink
Browse files

Update README for route maps using string keys instead of keywords

  • Loading branch information...
abhishek authored and weavejester committed Apr 20, 2010
1 parent 7574678 commit 21bf2d57541a91092851bcd50177c1f4f60e9987
Showing with 6 additions and 6 deletions.
  1. +6 −6 README.markdown
View
@@ -10,9 +10,9 @@ Here is an example of use:
user=> (use 'clout)
nil
user=> (route-matches "/article/:title" "/article/clojure")
- {:title "clojure"}
+ {"title" "clojure"}
user=> (route-matches "/public/*" "/public/style/screen.css")
- {:* "style/screen.css"}
+ {"*" "style/screen.css"}
Clout can also match Ring requests:
@@ -21,7 +21,7 @@ Clout can also match Ring requests:
:headers {"Host" "example.com"}
:uri "/book/123"}
:body nil})
- {:id "123"}
+ {"id" "123"}
Clout supports both keywords and wildcards. Keywords (like ":title") will
match any character but the following: `/ . , ; ?`. Wildcards will match
@@ -37,14 +37,14 @@ For additional performance, you can choose to pre-compile a route:
user=> (def user-route (route-compile "/user/:id"))
#'user/user-route
user=> (route-matches user-route "/user/10")
- {:user "10"}
+ {"user" "10"}
When compiling a route, you can specify a map of regular expressions to use
for different keywords. This allows more specific routing:
- user=> (def user-route (route-compile "/user/:id" {:id #"\d+"}))
+ user=> (def user-route (route-compile "/user/:id" {"id" #"\d+"}))
#'user/user-route
user=> (route-matches user-route "/user/10")
- {:user "10"}
+ {"user" "10"}
user=> (route-matches user-route "/user/jsmith")
nil

0 comments on commit 21bf2d5

Please sign in to comment.