Skip to content

Instantly share code, notes, and snippets.

@demosifter
Last active July 24, 2017 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demosifter/05569f3edde4b161673d9e35f6f0fdd6 to your computer and use it in GitHub Desktop.
Save demosifter/05569f3edde4b161673d9e35f6f0fdd6 to your computer and use it in GitHub Desktop.
const newResponse = (status_code, header, body) => {
return { status_code, header,
body: Buffer.from(JSON.stringify(body) || '').toString('base64')
}
}
module.exports = function (got) {
const inData = got.in.data;
console.log('edig: simple.js: data received:', inData);
return inData.map(d => {
let req = JSON.parse(d.value);
console.log(`${req.method}: ${req.request_uri}`);
let res = newResponse(200, {'Content-Type': ['text/plain; charset=utf-8']}, 'Nice one!');
return {
name: 'api_rpc',
key: d.key,
value: res
};
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment