metosin / sieppari

Small, fast, and complete interceptor library for Clojure/Script
Eclipse Public License 2.0
207 stars 21 forks source link

Consider including `with-bindings` support #54

Open robert-stuttaford opened 1 year ago

robert-stuttaford commented 1 year ago

Adding support for appears to be straight-forward:

https://github.com/metosin/sieppari/commit/bd54b969368df7945e175457ad8646cb93c8daa4

All one has to do is set :bindings on the context within any :enter interceptor:

(def ^:dynamic *transacting-user-id* nil)

(defn transacting-user-interceptor []
  {:name  ::transacting-user
   :enter (fn [ctx]
            (let [user-id (get-in ctx [:request :user :db/id])]
              (update ctx :bindings merge {#'*transacting-user-id* user-id})))})

I don't know enough about the async mode to know whether this is sufficient for that use-case.

jarppe commented 1 year ago

This is interesting, thank you. I will investigate this.

bnert commented 6 months ago

Gave implementing this a go in #55. Didn't want to be that guy and post "what's the status on this?" 😆.

Thanks @robert-stuttaford, for the starting point 🙂!