-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (27 loc) · 775 Bytes
/
index.js
File metadata and controls
32 lines (27 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var getRawBody = require('raw-body');
var getFormBody = require('body/form');
var body = require('body');
const BUILD_TIME = '{BUILD_TIME}';
const VERSION = '1.0.29';
exports.handler = (req, resp, context) => {
console.log('hello world');
var params = {
path: req.path,
queries: req.queries,
headers: req.headers,
method: req.method,
requestURI: req.url,
clientIP: req.clientIP,
version: VERSION,
buildVersion: BUILD_TIME,
};
getRawBody(req, function (err, body) {
for (var key in req.queries) {
var value = req.queries[key];
resp.setHeader(key, value);
}
resp.setHeader('Content-Type', 'application/json');
params.body = body.toString();
resp.send(JSON.stringify(params, null, ' '));
});
};