Skip to content

Commit

Permalink
Strip nils from :middleware. Fixes #228
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Apr 4, 2016
1 parent 62d6adb commit 6f0d7ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
@@ -1,4 +1,6 @@
## Unreleased
## 1.0.3-SNAPSHOT

* Strip nils from `:middleware`, fixes [#228](https://github.com/metosin/compojure-api/issues/228)

* updated dependencies:

Expand Down
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject metosin/compojure-api "1.0.2"
(defproject metosin/compojure-api "1.0.3-SNAPSHOT"
:description "Compojure Api"
:url "https://github.com/metosin/compojure-api"
:license {:name "Eclipse Public License"
Expand Down
1 change: 1 addition & 0 deletions src/compojure/api/middleware.clj
Expand Up @@ -250,5 +250,6 @@

(defn compose-middleware [middleware]
(->> middleware
(keep identity)
(map middleware-fn)
(apply comp identity)))
6 changes: 6 additions & 0 deletions test/compojure/api/middleware_test.clj
Expand Up @@ -80,3 +80,9 @@
(let [handler (-> (fn [_] (throw (ex-info "Error parsing request" {:type ::ex/request-parsing} (RuntimeException. "Kosh"))))
(wrap-exceptions (assoc-in default-options [:handlers ::ex/request-parsing] (ex/with-logging ex/request-parsing-handler :info))))]
(with-out-str (handler {})) => "INFO Error parsing request\n"))))

(facts "compose-middeleware strips nils aways. #228"
(let [times2-mw (fn [handler]
(fn [request]
(* 2 (handler request))))]
(((compose-middleware [nil times2-mw nil]) (constantly 3)) anything) => 6))

0 comments on commit 6f0d7ac

Please sign in to comment.