[Clojure] Add util method to set the api-context globally (#93)

This commit is contained in:
Fabrizio Ferrai 2018-05-18 06:22:02 +03:00 committed by William Cheng
parent d890d733f8
commit d7e374504f
2 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,11 @@
"Dynamic API context to be applied in API calls." "Dynamic API context to be applied in API calls."
default-api-context) default-api-context)
(defn set-api-context
"Set the *api-context* globally"
[new-context]
(alter-var-root #'*api-context* (constantly (merge *api-context* new-context))))
(defmacro with-api-context (defmacro with-api-context
"A helper macro to wrap *api-context* with default values." "A helper macro to wrap *api-context* with default values."
[api-context & body] [api-context & body]

View File

@ -24,6 +24,11 @@
"Dynamic API context to be applied in API calls." "Dynamic API context to be applied in API calls."
default-api-context) default-api-context)
(defn set-api-context
"Set the *api-context* globally"
[new-context]
(alter-var-root #'*api-context* (constantly (merge *api-context* new-context))))
(defmacro with-api-context (defmacro with-api-context
"A helper macro to wrap *api-context* with default values." "A helper macro to wrap *api-context* with default values."
[api-context & body] [api-context & body]