Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed deprecated wrap! function

  • Loading branch information...
commit 95f6797c9121c9b49b1a1c43327145879e8882d4 1 parent 7b14468
@weavejester authored
Showing with 0 additions and 55 deletions.
  1. +0 −31 src/compojure/core.clj
  2. +0 −24 test/compojure/test/core.clj
View
31 src/compojure/core.clj
@@ -166,34 +166,3 @@
(fn [request#]
(let-request [~args request#]
(routing request# ~@routes))))))
-
-(defn- middleware-sym [x]
- (symbol (namespace x) (str "wrap-" (name x))))
-
-(defn- ->middleware
- "Turn a keyword into a wrapper function symbol.
- e.g. :test => wrap-test
- (:test x) => (wrap-test x)"
- [kw]
- (cond
- (keyword? kw)
- (middleware-sym kw)
- (and (seq? kw) (keyword? (first kw)))
- (cons (middleware-sym (first kw)) (rest kw))
- :else
- kw))
-
-(defmacro wrap!
- "DEPRECATED: Use '->' instead.
- Wrap a handler in middleware functions. Uses the same syntax as the ->
- macro. Additionally, keywords may be used to denote a leading 'wrap-'.
- e.g.
- (wrap! foo (:session cookie-store))
- => (wrap! foo (wrap-session cookie-store))
- => (def foo (wrap-session foo cookie-store))"
- {:deprecated "0.6.0"}
- [handler & funcs]
- (let [funcs (map ->middleware funcs)]
- `(alter-var-root
- (var ~handler)
- (constantly (-> ~handler ~@funcs)))))
View
24 test/compojure/test/core.clj
@@ -111,27 +111,3 @@
"/foo/10/" "root"
"/foo/10/id" "10"
"/foo/1/x/2" "2"))))
-
-(deftest wrap-test
- (testing "wrap function"
- (defn func1 [x] (inc x))
- (let [wrapper (fn [f] (fn [x] (f (inc x))))]
- (wrap! func1 wrapper)
- (is (= (func1 3) 5))))
-
- (testing "wrap keyword"
- (defn func2 [x] (inc x))
- (defn wrap-test1 [f]
- (fn [x] (f (* 2 x))))
- (wrap! func2 :test1)
- (is (= (func2 3) 7)))
-
- (testing "wrap namespaced keyword"
- (defn func3 [x] (inc x))
- (wrap! func3 :testns/test2)
- (is (= (func3 3) 10)))
-
- (testing "wrap function and keyword"
- (defn func4 [x] (inc x))
- (wrap! func4 wrap-test1 :test1)
- (is (= (func4 3) 13))))
Please sign in to comment.
Something went wrong with that request. Please try again.