You've already forked serverless-offline
mirror of
https://github.com/encounter/serverless-offline.git
synced 2026-03-30 11:37:53 -07:00
10558c8283
This change introduces request.rawPayload to the Hapi request and uses that if request.payload is not a string. Before, JSON.stringify(JSON.parse(request.payload)) was being used, which is not the same as the rawPayload that should be passed along.
42 lines
801 B
JavaScript
42 lines
801 B
JavaScript
'use strict';
|
|
|
|
module.exports = class RequestBuilder {
|
|
constructor(method, path) {
|
|
this.request = {
|
|
method: method.toUpperCase(),
|
|
headers: {},
|
|
unprocessedHeaders: {},
|
|
params: {},
|
|
route: {
|
|
path,
|
|
},
|
|
query: {},
|
|
payload: null,
|
|
rawPayload: null,
|
|
info: {
|
|
remoteAddress: '127.0.0.1',
|
|
},
|
|
};
|
|
}
|
|
|
|
addHeader(key, value) {
|
|
this.request.headers[key] = value;
|
|
this.request.unprocessedHeaders[key] = value;
|
|
}
|
|
|
|
addBody(body) {
|
|
this.request.payload = body;
|
|
|
|
// The rawPayload would normally be the string version of the given body
|
|
this.request.rawPayload = JSON.stringify(body);
|
|
}
|
|
|
|
addParam(key, value) {
|
|
this.request.params[key] = value;
|
|
}
|
|
|
|
toObject() {
|
|
return this.request;
|
|
}
|
|
};
|