Skip to content
This repository
Browse code

Support for lists in context macro (fixes #56)

  • Loading branch information...
commit 4cf73d6e3b72ac151abac92d05ac5e8201657493 1 parent 34a9687
James Reeves authored

Showing 2 changed files with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  src/compojure/core.clj
  2. +4 0 test/compojure/test/core.clj
2  src/compojure/core.clj
@@ -158,7 +158,7 @@
158 158 `(route-compile
159 159 ~(str (first route) ":__path-info")
160 160 ~(merge (apply hash-map (rest route)) re-context))
161   - (symbol? route)
  161 + :else
162 162 `(route-compile (str ~route ":__path-info") ~re-context))))
163 163
164 164 (defmacro context
4 test/compojure/test/core.clj
@@ -97,6 +97,10 @@
97 97 handler (context path [id] identity)]
98 98 (is (map? (handler (request :get "/foo/10"))))
99 99 (is (nil? (handler (request :get "/bar/10"))))))
  100 + (testing "list matching"
  101 + (let [handler (context (str "/foo" "/:id") [id] identity)]
  102 + (is (map? (handler (request :get "/foo/10"))))
  103 + (is (nil? (handler (request :get "/bar/10"))))))
100 104 (testing "context key"
101 105 (let [handler (context "/foo/:id" [id] :context)]
102 106 (are [url ctx] (= (handler (request :get url)) ctx)

0 comments on commit 4cf73d6

Please sign in to comment.
Something went wrong with that request. Please try again.