fix http get params map not always being passed in

This commit is contained in:
Gered 2017-03-01 11:25:40 -05:00
parent ed94b10d74
commit 8684899bfa

View file

@ -41,6 +41,13 @@
`(binding [*options* (select-keys ~options [:basic-auth :digest-auth :oauth-token :headers :insecure?])] `(binding [*options* (select-keys ~options [:basic-auth :digest-auth :oauth-token :headers :insecure?])]
~@body)) ~@body))
(defn- get-base-http-req-params
[]
(merge
(if (:insecure? *options*) {:insecure? true})
(select-keys *options* [:basic-auth :digest-auth :oauth-token])
(if (map? (:headers *options*)) {:headers (:headers *options*)})))
(defn- ->fhir-resource-name [x] (defn- ->fhir-resource-name [x]
(name (->CamelCase x))) (name (->CamelCase x)))
@ -53,10 +60,7 @@
url (build-url base-url resource-url (if-not params-as-body? query)) url (build-url base-url resource-url (if-not params-as-body? query))
body (if params-as-body? query body) body (if params-as-body? query body)
follow-location? (if (nil? follow-location?) true follow-location?) follow-location? (if (nil? follow-location?) true follow-location?)
http-req-params (merge http-req-params (get-base-http-req-params)]
(if (:insecure? *options*) {:insecure? true})
(select-keys *options* [:basic-auth :digest-auth :oauth-token])
(if (map? (:headers *options*)) {:headers (:headers *options*)}))]
(try (try
(let [response (case type (let [response (case type
:get (http-get-json url http-req-params) :get (http-get-json url http-req-params)
@ -68,7 +72,7 @@
location (get-in response [:headers "Location"])] location (get-in response [:headers "Location"])]
(if location (if location
(if follow-location? (if follow-location?
(-> (http-get-json location) (-> (http-get-json location http-req-params)
:body :body
(json/parse-string true)) (json/parse-string true))
(if (fhir-response? response) (if (fhir-response? response)
@ -345,7 +349,8 @@
paging: http://hl7.org/implement/standards/fhir/http.html#paging" paging: http://hl7.org/implement/standards/fhir/http.html#paging"
[bundle] [bundle]
(if-let [next-url (get-bundle-next-page-url bundle)] (if-let [next-url (get-bundle-next-page-url bundle)]
(http-get-json next-url))) (let [http-req-params (get-base-http-req-params)]
(http-get-json next-url http-req-params))))
(defn- concat-bundle-entries [bundle other-bundle] (defn- concat-bundle-entries [bundle other-bundle]
(if (nil? bundle) (if (nil? bundle)