diff options
author | EuAndreh <eu@euandre.org> | 2024-03-15 12:55:07 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-03-15 12:55:07 -0300 |
commit | b28393ee10aa7b90968d546ef781488fe636eef0 (patch) | |
tree | d45542b63c02a71e668e883a1af86e07fab7162a /src | |
parent | src/hero.mjs: Add buildHttpPayload() (diff) | |
download | papod-b28393ee10aa7b90968d546ef781488fe636eef0.tar.gz papod-b28393ee10aa7b90968d546ef781488fe636eef0.tar.xz |
src/hero.mjs: Add support for "WEBSOCKET" type of route
Diffstat (limited to 'src')
-rw-r--r-- | src/hero.mjs | 9 |
1 files changed, 7 insertions, 2 deletions
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, ); }; |