Permalink
Browse files

add-custom-middleware in server/handler

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
1 parent 872daba commit f868d9a9f5953c3dc0b396050d2045d5a33d96b9 @ibdknox ibdknox committed Aug 17, 2011
Showing with 7 additions and 2 deletions.
  1. +2 −2 src/noir/server.clj
  2. +5 −0 src/noir/server/handler.clj
View
@@ -37,8 +37,8 @@
"Add a middleware function to the noir server. Func is a standard ring middleware
function, which will be passed the handler. Any extra args to be applied should be
supplied along with the function."
- [func & args]
- (swap! handler/middleware conj [func args]))
+ [& args]
+ (apply handler/add-custom-middleware args))
(defn start
"Create a noir server bound to the specified port with a map of options and return it.
@@ -43,6 +43,11 @@
(pack-routes))
(wrap-custom-middleware))))
+(defn add-custom-middleware
+ "Add a middleware function to all noir handlers."
+ [func & args]
+ (swap! middleware conj [func args]))
+
(defn wrap-noir-middleware
"Wrap a base handler in all of noir's middleware"
[handler opts]

0 comments on commit f868d9a

Please sign in to comment.