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

Middleware registry / lookup #32

Closed
ikitommi opened this issue Sep 8, 2017 · 1 comment
Closed

Middleware registry / lookup #32

ikitommi opened this issue Sep 8, 2017 · 1 comment

Comments

@ikitommi
Copy link
Member

ikitommi commented Sep 8, 2017

It could be useful to be able to reference Middleware by their distinct names instead of instances. Names would be looked from explicit registry. Registry could be a map (name -> middleware) or via a registry construcing function , consuming a vector of Middleware instances. :name of Middleware could be used as a key.

Something like:

(extend-protocol IntoMiddleware
  #?(:clj  clojure.lang.Keyword
     :cljs cljs.core.Keyword)
  (into-middleware [this _ {:keys [middleware-registry]}]
    (into-middleware (middleware-registry this))))

allowing:

(require '[reitit.ring :as ring])

(ring/ring-router
  ["/api" {:middleware [::api-format]}
   ["/ping" (constantly {:status 200, :body {:ping "pong"}})]]
  {:middleware-registry {::api-format ....})

Related: macchiato-framework/macchiato-core#9

@ikitommi
Copy link
Member Author

Coming in 0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant