mirror of https://github.com/Seich/Beau.git
Modifiers can now edit request settings.
This gives a lot more flexibility when it comes to what a modifier can do. They can now use any valid request option to change how the response behaves.
This commit is contained in:
parent
f13cbda84a
commit
d15564a9e3
|
|
@ -5,6 +5,7 @@ class Modifiers {
|
|||
}
|
||||
|
||||
preRequest(request, orig) {
|
||||
request.headers = request.headers || {};
|
||||
request.headers.preRequestModifier = true;
|
||||
return request;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,13 +77,20 @@ class Request {
|
|||
|
||||
async exec(cache = new RequestCache()) {
|
||||
let settings = cache.parse({
|
||||
endpoint: this.ENDPOINT,
|
||||
url: this.ENDPOINT,
|
||||
method: this.VERB,
|
||||
|
||||
headers: this.HEADERS,
|
||||
query: this.PARAMS,
|
||||
payload: this.PAYLOAD
|
||||
qs: this.PARAMS,
|
||||
body: this.PAYLOAD,
|
||||
|
||||
json: true,
|
||||
simple: false,
|
||||
resolveWithFullResponse: true
|
||||
});
|
||||
|
||||
settings = removeOptionalKeys(settings, ['headers', 'qs', 'body']);
|
||||
|
||||
settings = this.plugins.replaceDynamicValues(settings);
|
||||
|
||||
settings = this.plugins.executeModifier(
|
||||
|
|
@ -93,23 +100,7 @@ class Request {
|
|||
);
|
||||
|
||||
try {
|
||||
const response = await request(
|
||||
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']
|
||||
)
|
||||
);
|
||||
const response = await request(settings);
|
||||
|
||||
let results = {
|
||||
request: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue