Fork me on GitHub
#pedestal
<
2018-06-09
>
ikitommi17:06:46

could someone explain the :bindings in the context map? what is the use case for them?

ikitommi17:06:54

> As accepted by clojure.core/with-bindings. Prior to delegating execution to any interceptor, the interceptor framework will ensure that the bindings specified in this map are installed using clojure.core/with-bindings. If this map is altered and included in the returned context from an interceptor, the new bindings in the map will be installed as thread local bindings prior to another interceptor’s execution.

souenzzo17:06:22

if you do (bindings [db (get-db)] (run-query)) then you can create a chain like [interceptor-get-db handler-run-query]

ikitommi18:06:00

thanks. Is there a case where that is better/recommended over to just assoccing in the db-con into context and thus making the binding explicit? Thread locals are really slow both to read & write.