Make the headers a function.
This commit is contained in:
parent
6710acc1b9
commit
a36202b167
|
@ -7,7 +7,8 @@
|
||||||
(def api-config (atom {:api-host "https://api.sendgrid.com/"
|
(def api-config (atom {:api-host "https://api.sendgrid.com/"
|
||||||
:api-key (h/get-env "SENDGRID_API_KEY" "NO API KEY SUPPLIED")}))
|
:api-key (h/get-env "SENDGRID_API_KEY" "NO API KEY SUPPLIED")}))
|
||||||
|
|
||||||
(def default-authed-payload {:headers {"Authorization" (str "Bearer " (:api-key @api-config))
|
(defn default-authed-payload []
|
||||||
|
{:headers {"Authorization" (str "Bearer " (:api-key @api-config))
|
||||||
"content-type" "application/json"}})
|
"content-type" "application/json"}})
|
||||||
|
|
||||||
(defn init-config [cfg]
|
(defn init-config [cfg]
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
(defn send-email
|
(defn send-email
|
||||||
"https://docs.sendgrid.com/api-reference/mail-send/mail-send"
|
"https://docs.sendgrid.com/api-reference/mail-send/mail-send"
|
||||||
[email]
|
[email]
|
||||||
(merge default-authed-payload
|
(merge (default-authed-payload)
|
||||||
{:uri (build-url "/mail/send")
|
{:uri (build-url "/mail/send")
|
||||||
:method :post
|
:method :post
|
||||||
:format (json-request-format)
|
:format (json-request-format)
|
||||||
|
|
Loading…
Reference in New Issue