fix: fix octavia request headers
Add accept:application/json to all the octavia requests, to get the return data in json format, otherwise it may get the return data in xml format Closes-Bug: #1990250 Change-Id: Ibb3c2540225631ba9d3c972d5ac123d8b007d4e8
This commit is contained in:
parent
fdcf5c14b2
commit
19d0cf2003
@ -20,6 +20,40 @@ export class OctaviaClient extends Base {
|
|||||||
return octaviaBase();
|
return octaviaBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get request() {
|
||||||
|
const request = this.originRequest;
|
||||||
|
if (!this.enable) {
|
||||||
|
return super.request;
|
||||||
|
}
|
||||||
|
const updateConfig = (conf) => {
|
||||||
|
const { headers = {}, ...rest } = conf || {};
|
||||||
|
const newConf = {
|
||||||
|
headers: {
|
||||||
|
accept: 'application/json',
|
||||||
|
...headers,
|
||||||
|
},
|
||||||
|
...rest,
|
||||||
|
};
|
||||||
|
return newConf;
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
get: (url, params, conf) =>
|
||||||
|
request.get(this.getUrl(url), params, updateConfig(conf)),
|
||||||
|
post: (url, data, params, conf) =>
|
||||||
|
request.post(this.getUrl(url), data, params, updateConfig(conf)),
|
||||||
|
put: (url, data, params, conf) =>
|
||||||
|
request.put(this.getUrl(url), data, params, updateConfig(conf)),
|
||||||
|
delete: (url, data, params, conf) =>
|
||||||
|
request.delete(this.getUrl(url), data, params, updateConfig(conf)),
|
||||||
|
patch: (url, data, params, conf) =>
|
||||||
|
request.patch(this.getUrl(url), data, params, updateConfig(conf)),
|
||||||
|
head: (url, params, conf) =>
|
||||||
|
request.head(this.getUrl(url), params, updateConfig(conf)),
|
||||||
|
copy: (url, params, conf) =>
|
||||||
|
request.copy(this.getUrl(url), params, updateConfig(conf)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
get resources() {
|
get resources() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user