Skip to content

Commit 939c60c

Browse files
committed
Pass metadata info
1 parent ed7968c commit 939c60c

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/api.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ class DICOMwebClient {
177177
}
178178

179179
if ("enhancers" in options) {
180-
const pipe = functions => args => functions.reduce((arg, fn) => fn(arg), args);
180+
const metadata = { method, url };
181+
const pipe = functions => (args) => functions.reduce((args, fn) => fn(args, metadata), args);
181182
const pipedRequest = pipe(options.enhancers);
182183
request = pipedRequest(request);
183184
}
@@ -201,11 +202,9 @@ class DICOMwebClient {
201202
* @private
202203
*/
203204
_httpGet(url, headers, responseType, progressCallback) {
204-
return this._httpRequest(url, "get", headers, {
205-
responseType,
206-
progressCallback,
207-
enhancers: this.enhancers
208-
});
205+
const options = { responseType, progressCallback };
206+
if (this.enhancers) options.enhancers = this.enhancers;
207+
return this._httpRequest(url, "get", headers, options);
209208
}
210209

211210
/**
@@ -641,11 +640,9 @@ class DICOMwebClient {
641640
* @returns {Promise} Response
642641
*/
643642
_httpPost(url, headers, data, progressCallback) {
644-
return this._httpRequest(url, "post", headers, {
645-
data,
646-
progressCallback,
647-
enhancers: this.enhancers
648-
});
643+
const options = { data, progressCallback };
644+
if (this.enhancers) options.enhancers = this.enhancers;
645+
return this._httpRequest(url, "post", headers, options);
649646
}
650647

651648
/**

0 commit comments

Comments
 (0)