Skip to content

Commit 629aad4

Browse files
timursevimlitshemsedinov
authored andcommitted
Fix http transport
1 parent e30d714 commit 629aad4

File tree

1 file changed

+7
-3
lines changed
  • JavaScript/b-transport/transport

1 file changed

+7
-3
lines changed

JavaScript/b-transport/transport/http.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ module.exports = (routing, port, console) => {
2424
res.writeHead(200, HEADERS);
2525
if (req.method !== 'POST') return void res.end('"Not found"');
2626
const { url, socket } = req;
27-
const [place, name, method] = url.substring(1).split('/');
27+
const [place, name, method, id] = url.substring(1).split('/');
2828
if (place !== 'api') return void res.end('"Not found"');
2929
const entity = routing[name];
3030
if (!entity) return void res.end('"Not found"');
3131
const handler = entity[method];
3232
if (!handler) return void res.end('"Not found"');
33-
const { args } = await receiveArgs(req);
33+
const src = handler.toString();
34+
const signature = src.substring(0, src.indexOf(')'));
35+
const args = [];
36+
if (signature.includes('(id')) args.push(id);
37+
if (signature.includes('{')) args.push(await receiveArgs(req));
3438
console.log(`${socket.remoteAddress} ${method} ${url}`);
35-
const result = await handler(args);
39+
const result = await handler(...args);
3640
res.end(JSON.stringify(result));
3741
}).listen(port);
3842

0 commit comments

Comments
 (0)