Permalink
Browse files

Added nested-params middleware

  • Loading branch information...
1 parent 2ce108b commit d636bfdc865bd09e34a61796c82a303c4f0cb0d5 @weavejester committed Dec 18, 2010
Showing with 20 additions and 8 deletions.
  1. +1 −0 src/compojure/core.clj
  2. +19 −8 test/compojure/test/core.clj
View
@@ -71,6 +71,7 @@
[& handlers]
(-> (fn [req] (some #(% req) handlers))
wrap-keyword-params
+ wrap-nested-params
wrap-params
wrap-cookies))
@@ -41,20 +41,31 @@
route (PUT "/foo" [] resp)]
(is (= (route req) resp))))
- (testing "custom regexes"
+ (testing "custom regular expressions"
(expect [route-compile
(has-args ["/foo/:id" {:id "[0-9]+"}]
(times 1))]
(eval `(GET ["/foo/:id" :id "[0-9]+"] [])))))
(deftest routes-test
- ((routes
- (GET "/:x" [x y & more]
- (is (= x "foo"))
- (is (= y "bar"))
- (is (= more {:z "baz"}))
- nil))
- (request :get "/foo" {:y "bar", :z "baz"})))
+ (testing "keyword parameters"
+ ((routes
+ (GET "/:x" [x y & more]
+ (is (= x "foo"))
+ (is (= y "bar"))
+ (is (= more {:z "baz"}))
+ nil))
+ (request :get "/foo" {:y "bar", :z "baz"})))
+ (testing "nested parameters"
+ ((routes
+ (GET "/" [x y]
+ (is (= x {:a "1", :b "2"}))
+ (is (= y ["3" "4"]))
+ nil))
+ (request :get "/" [["x[a]" "1"]
+ ["x[b]" "2"]
+ ["y[]" "3"]
+ ["y[]" "4"]]))))
(deftest wrap
(testing "wrap function"

0 comments on commit d636bfd

Please sign in to comment.