diff options
| author | EuAndreh <eu@euandre.org> | 2024-03-14 12:55:30 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2024-03-14 12:55:30 -0300 |
| commit | 06d1483ed03883745ea76b4481a10dee16800d50 (patch) | |
| tree | 2b3b5d49472180ca04bf369f8d42b65fed35ef08 /src | |
| parent | Makefile: Add "run-binder" to expose lighttpd's unix socket to a TCP port (diff) | |
| download | papod-06d1483ed03883745ea76b4481a10dee16800d50.tar.gz papod-06d1483ed03883745ea76b4481a10dee16800d50.tar.xz | |
src/hero.mjs: Include "headers" and "ref" in request param
Diffstat (limited to 'src')
| -rw-r--r-- | src/hero.mjs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/hero.mjs b/src/hero.mjs index 3955eed..c4cf0b2 100644 --- a/src/hero.mjs +++ b/src/hero.mjs @@ -242,7 +242,8 @@ export const make404Handler = interceptors => ({ handlerFn: wrapHandler(handle404, interceptors), }); -export const handleRequest = async (table, method, url) => { +export const handleRequest = async (table, reqHandle) => { + const { method, url, headers } = reqHandle; const [ path, queryParams ] = url.split("?"); const handler = ( findHandler(table, method, path) || @@ -256,16 +257,18 @@ export const handleRequest = async (table, method, url) => { }, method, path, + headers, handler: handler.handlerFn, + ref: reqHandle, }; return await handler.handlerFn(request); }; export const makeRequestListener = table => async (req, res) => { - const response = await handleRequest(table, req.method, req.url); - res.writeHead(response.status, response.headers); - res.end(response.body); + const { status, headers, body } = await handleRequest(table, req); + res.writeHead(status, headers); + res.end(body); }; export const actionsFn = ({ |
