From b28393ee10aa7b90968d546ef781488fe636eef0 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 15 Mar 2024 12:55:07 -0300 Subject: src/hero.mjs: Add support for "WEBSOCKET" type of route --- src/hero.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/hero.mjs') diff --git a/src/hero.mjs b/src/hero.mjs index daf8141..10fa06e 100644 --- a/src/hero.mjs +++ b/src/hero.mjs @@ -172,12 +172,17 @@ export const addRoute = (table, methods, path, handlerFn) => { return addRoute(table, [methods], path, handlerFn); } - assert.ok(methods.every(m => HTTP_METHODS.has(m))); + assert.ok(methods.every(isValidLabel)); const segments = pathToSegments(path); const kw = hasPathParams(segments) ? "dynamic" : "static"; return methods.reduce( - (acc, el) => u.assocIn(acc, [kw, el].concat(segments), handlerFn), + (acc, el) => + u.assocIn( + acc, + comboForLabel(el, kw).concat(segments), + handlerFn, + ), table, ); }; -- cgit v1.2.3