Last active
July 24, 2017 10:29
-
-
Save demosifter/05569f3edde4b161673d9e35f6f0fdd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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