Skip to content

Commit

Permalink
Removed default middleware from routes
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Dec 29, 2010
1 parent 876e5f3 commit 0f2b10d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
12 changes: 2 additions & 10 deletions src/compojure/core.clj
Expand Up @@ -2,11 +2,7 @@
"A concise syntax for generating Ring handlers."
(:use clojure.contrib.def
clout.core
compojure.response
[ring.middleware params
keyword-params
nested-params
cookies]))
compojure.response))

(defn- method-matches
"True if this request matches the supplied method."
Expand Down Expand Up @@ -88,11 +84,7 @@
(defn routes
"Create a Ring handler by combining several handlers into one."
[& handlers]
(-> #(apply routing % handlers)
wrap-keyword-params
wrap-nested-params
wrap-params
wrap-cookies))
#(apply routing % handlers))

(defmacro defroutes
"Define a Ring handler function from a sequence of routes. The name may be
Expand Down
29 changes: 4 additions & 25 deletions test/compojure/test/core.clj
Expand Up @@ -63,31 +63,10 @@
(GET "/bar" [] (is true) nil)))

(deftest routes-test
(testing "multiple routes"
((routes
(GET "/foo" [] (is false) nil)
(GET "/bar" [] (is true) nil))
(request :get "/bar")))

(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"]]))))
((routes
(GET "/foo" [] (is false) nil)
(GET "/bar" [] (is true) nil))
(request :get "/bar")))

(deftest wrap
(testing "wrap function"
Expand Down

0 comments on commit 0f2b10d

Please sign in to comment.