Support for reading post bodies from incoming HTTP requests

This commit is contained in:
Tony Garnock-Jones 2018-12-13 16:40:24 +00:00
parent d1877a890c
commit 074f7f1d35
2 changed files with 3 additions and 0 deletions

View File

@ -20,6 +20,7 @@
},
"dependencies": {
"@syndicate-lang/core": "^0.0.20",
"@syndicate-lang/driver-streams-node": "^0.0.2",
"ws": "^6.1.2"
}
}

View File

@ -22,6 +22,7 @@ import { parse as parseUrl } from "url";
const http = require('http');
const https = require('https');
const _WebSocket = require('ws');
const S = activate require("@syndicate-lang/driver-streams-node");
assertion type HttpServer(host, port);
assertion type HttpsServer(host, port, options);
@ -169,6 +170,7 @@ function _server(host, port, httpsOptions) {
res.writeHead(500, "Internal server error", {});
res.end();
}
on asserted Observe(S.Readable(id)) react S.readableStreamBehaviour(id, req);
on asserted Response(id, $code, $message, $headers, $detail)
{
res.writeHead(code, message, headers.toJS());