Make the headers a function.

This commit is contained in:
Oliver Marks 2024-02-02 21:10:41 +00:00
parent 6710acc1b9
commit a36202b167
1 changed files with 4 additions and 3 deletions

View File

@ -7,8 +7,9 @@
(def api-config (atom {:api-host "https://api.sendgrid.com/"
:api-key (h/get-env "SENDGRID_API_KEY" "NO API KEY SUPPLIED")}))
(def default-authed-payload {:headers {"Authorization" (str "Bearer " (:api-key @api-config))
"content-type" "application/json"}})
(defn default-authed-payload []
{:headers {"Authorization" (str "Bearer " (:api-key @api-config))
"content-type" "application/json"}})
(defn init-config [cfg]
(reset! api-config (merge @api-config cfg)))
@ -19,7 +20,7 @@
(defn send-email
"https://docs.sendgrid.com/api-reference/mail-send/mail-send"
[email]
(merge default-authed-payload
(merge (default-authed-payload)
{:uri (build-url "/mail/send")
:method :post
:format (json-request-format)