mirror of https://github.com/Seich/Beau.git
Merge pull request #9 from Seich/next-plugin-improvements
Modifiers can now edit request settings.
This commit is contained in:
commit
6c552cb7a2
|
|
@ -5,6 +5,7 @@ class Modifiers {
|
||||||
}
|
}
|
||||||
|
|
||||||
preRequest(request, orig) {
|
preRequest(request, orig) {
|
||||||
|
request.headers = request.headers || {};
|
||||||
request.headers.preRequestModifier = true;
|
request.headers.preRequestModifier = true;
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,13 +77,20 @@ class Request {
|
||||||
|
|
||||||
async exec(cache = new RequestCache()) {
|
async exec(cache = new RequestCache()) {
|
||||||
let settings = cache.parse({
|
let settings = cache.parse({
|
||||||
endpoint: this.ENDPOINT,
|
url: this.ENDPOINT,
|
||||||
method: this.VERB,
|
method: this.VERB,
|
||||||
|
|
||||||
headers: this.HEADERS,
|
headers: this.HEADERS,
|
||||||
query: this.PARAMS,
|
qs: this.PARAMS,
|
||||||
payload: this.PAYLOAD
|
body: this.PAYLOAD,
|
||||||
|
|
||||||
|
json: true,
|
||||||
|
simple: false,
|
||||||
|
resolveWithFullResponse: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
settings = removeOptionalKeys(settings, ['headers', 'qs', 'body']);
|
||||||
|
|
||||||
settings = this.plugins.replaceDynamicValues(settings);
|
settings = this.plugins.replaceDynamicValues(settings);
|
||||||
|
|
||||||
settings = this.plugins.executeModifier(
|
settings = this.plugins.executeModifier(
|
||||||
|
|
@ -93,23 +100,7 @@ class Request {
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await request(
|
const response = await request(settings);
|
||||||
removeOptionalKeys(
|
|
||||||
{
|
|
||||||
url: settings.endpoint,
|
|
||||||
method: settings.method,
|
|
||||||
|
|
||||||
headers: settings.headers,
|
|
||||||
qs: settings.query,
|
|
||||||
body: settings.payload,
|
|
||||||
|
|
||||||
json: true,
|
|
||||||
simple: false,
|
|
||||||
resolveWithFullResponse: true
|
|
||||||
},
|
|
||||||
['headers', 'qs', 'body']
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
let results = {
|
let results = {
|
||||||
request: {
|
request: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue