Skip to content

Commit

Permalink
[Clojure] Add util method to set the api-context globally (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
f-f authored and wing328 committed May 18, 2018
1 parent d890d73 commit d7e3745
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"Dynamic API context to be applied in API calls."
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
"A helper macro to wrap *api-context* with default values."
[api-context & body]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"Dynamic API context to be applied in API calls."
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
"A helper macro to wrap *api-context* with default values."
[api-context & body]
Expand Down

0 comments on commit d7e3745

Please sign in to comment.