Skip to content

Loading…

Remove duplicate wrap-custom-middleware #103

Merged
merged 1 commit into from

2 participants

@kenrestivo

An extra wrap-custom-middleware was causing middlewares to get wrapped twice, and thus be executed 2 (or 3) times per each request. This was a problem because I was trying to write a middleware which has side-effects, and getting called multiple times per requests is not OK.

Traceback of a middleware at its execution, was:

** 1st time:

             handler.clj:67 noir.server.handler/wrap-custom-middleware
             handler.clj:95 noir.server.handler/init-routes
            handler.clj:136 noir.server.handler/base-handler
            RestFn.java:408 clojure.lang.RestFn.invoke
              server.clj:16 noir.server/gen-handler

** 2nd time:
                handler.clj:65 noir.server.handler/wrap-custom-middleware[fn]
            ArrayChunk.java:58 clojure.lang.ArrayChunk.reduce
              protocols.clj:30 clojure.core.protocols/fn
              protocols.clj:11 clojure.core.protocols/fn[fn]
                 core.clj:5995 clojure.core/reduce
                handler.clj:67 noir.server.handler/wrap-custom-middleware
               handler.clj:124 noir.server.handler/wrap-spec-routes
                 server.clj:16 noir.server/gen-handler

This patch deletes the second wrap-custom-middleware. After applying this patch, middleware gets wrapped exactly once.

@Raynes
noir-clojure member

Wow. That must have sucked. Thanks!

@Raynes Raynes merged commit 5178c1d into noir-clojure:master
@kenrestivo

No prob, glad to have found it.

BTW I have a few other pull requests waiting in your queue, if you want to take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 14, 2012
  1. @kenrestivo

    remove duplciate wrap-custom-middleware which had been causing middle…

    kenrestivo committed
    …ware handlers to execute multiple times per request
Showing with 0 additions and 1 deletion.
  1. +0 −1 src/noir/server/handler.clj
View
1 src/noir/server/handler.clj
@@ -120,7 +120,6 @@
[handler opts]
(routes handler
(-> (apply routes (spec-routes))
- (wrap-custom-middleware)
(cookie/wrap-noir-cookies)
(validation/wrap-noir-validation)
(hiccup/wrap-base-url (options/get :base-url))
Something went wrong with that request. Please try again.