Skip to content

Commit bd71f6d

Browse files
timursevimlitshemsedinov
authored andcommitted
Update http.js
1 parent 629aad4 commit bd71f6d

File tree

1 file changed

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

1 file changed

+4
-3
lines changed

JavaScript/b-transport/transport/http.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ 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, id] = url.substring(1).split('/');
27+
const [place, name, method] = 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"');
3333
const src = handler.toString();
3434
const signature = src.substring(0, src.indexOf(')'));
35+
const body = await receiveArgs(req);
3536
const args = [];
36-
if (signature.includes('(id')) args.push(id);
37-
if (signature.includes('{')) args.push(await receiveArgs(req));
37+
if (signature.includes('(id')) args.push(body.id);
38+
if (signature.includes('{')) args.push(...body);
3839
console.log(`${socket.remoteAddress} ${method} ${url}`);
3940
const result = await handler(...args);
4041
res.end(JSON.stringify(result));

0 commit comments

Comments
 (0)