Skip to content

Instantly share code, notes, and snippets.

@demosifter
Last active Jul 24, 2017
Embed
What would you like to do?
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