summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hero.mjs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/hero.mjs b/src/hero.mjs
index 314360c..2168ff7 100644
--- a/src/hero.mjs
+++ b/src/hero.mjs
@@ -445,6 +445,19 @@ export const makeRequestListener = table => async (req, res) => {
res.end(body);
};
+export const makeUpgradeListener = table => async (req, socket, _head) => {
+ assert.ok(req.upgrade);
+ const { status, headers, body } = await handleRequest(table, {
+ ...req,
+ socket,
+ });
+ writeHead(socket, status, headers);
+ socket.write(body);
+ if (status !== 101) {
+ socket.end();
+ }
+};
+
export const actionsFn = ({
logger = log,
} = {}) => ({