Skip to content

Instantly share code, notes, and snippets.

@emidln emidln/system.clj
Created Sep 25, 2015

Embed
What would you like to do?
(defrecord RingHandler
[handler injections app]
component/Lifecycle
(start [this]
(if app
this
(let [app (fn [req]
(let [injectables (select-keys this injections)]
(handler
(if (empty? injectables)
req
(apply assoc req (apply concat injectables))))))]
(assoc this :app app))))
(stop [this]
(if this
(dissoc this :app)
this)))
(defn new-ring-handler
([handler]
(new-ring-handler handler nil))
([handler injections]
(map->RingHandler {:handler http
:injections injections})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.