Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to add middleware higher up in the wrap stack #107

Open
kenrestivo opened this issue May 31, 2012 · 0 comments
Open

Ability to add middleware higher up in the wrap stack #107

kenrestivo opened this issue May 31, 2012 · 0 comments

Comments

@kenrestivo
Copy link
Contributor

I've written a custom middlleware to try/catch/rethrow and send exception reports via email and other means. But add-custom-middleware wraps it in after routing, but before cookie and session handling. If there are errors in session handling (i.e. if the session store is database-backed and the db access has problems), it doesn't get caught by the middleware.

It'd be nice to have a wrap-custom-exception-handler which would wrap a handle in or after the add-noir-middleware function. I'd be happy to do it, if I could get some guidance as to how you'd like it to be named and to behave.

To keep it simple, if there's really only likely to be one custom exception handler anyway, maybe I could add it as a server opt :custom-exeption-handler, then wrap it from inside add-noir-middleware. Otherwise, maybe another atom and add-custom-exception-handler?

Background:

                   welcome.clj:225 exceptiontest.views.welcome/GET--blowup
                   welcome.clj:224 exceptiontest.views.welcome/eval3185[fn]
                       core.clj:39 compojure.core/if-route[fn]
                       core.clj:24 compojure.core/if-method[fn]
                       core.clj:98 compojure.core/routing[fn]
                     core.clj:2388 clojure.core/some
                       core.clj:98 compojure.core/routing
                   RestFn.java:139 clojure.lang.RestFn.applyTo
                      core.clj:602 clojure.core/apply
                      core.clj:103 compojure.core/routes[fn]
                    request.clj:14 noir.request/wrap-request-map[fn]
(init-routes) --->>    core.clj:42 firealarm.core/exception-wrapper[fn]     <<-- this is where custom middleware gets wrapped in.

                 middleware.clj:12 hiccup.middleware/wrap-base-url[fn]
                    session.clj:92 noir.session/noir-flash[fn]
                      flash.clj:14 ring.middleware.flash/wrap-flash[fn]
                    session.clj:56 noir.session/noir-session[fn]
                    session.clj:40 ring.middleware.session/wrap-session[fn]
                   cookies.clj:160 ring.middleware.cookies/wrap-cookies[fn]
                    cookies.clj:66 noir.cookies/noir-cookies[fn]
                   cookies.clj:160 ring.middleware.cookies/wrap-cookies[fn]
                validation.clj:121 noir.validation/wrap-noir-validation[fn]
                   statuses.clj:34 noir.statuses/wrap-status-pages[fn]
                  exception.clj:57 noir.exception/wrap-exceptions[fn]
=====>              options.clj:34 noir.options/wrap-options[fn]         <<---- this is where I'd rather add the exception handler instead
(^^^   wrap-noir-middleware)                                                        
                       core.clj:98 compojure.core/routing[fn]
                     core.clj:2388 clojure.core/some
                       core.clj:98 compojure.core/routing
                   RestFn.java:139 clojure.lang.RestFn.applyTo
                      core.clj:602 clojure.core/apply
                      core.clj:103 compojure.core/routes[fn]
             keyword_params.clj:27 ring.middleware.keyword-params/wrap-keyword-params[fn]
              nested_params.clj:65 ring.middleware.nested-params/wrap-nested-params[fn]
                     params.clj:55 ring.middleware.params/wrap-params[fn]
===>      multipart_params.clj:103 ring.middleware.multipart-params/wrap-multipart-params[fn]   <<-- or even here, maybe
(^ gen-handler)
                      jetty.clj:18 ring.adapter.jetty/proxy-handler[fn]
                  (Unknown Source) ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant