additional keys for history mode

This commit is contained in:
2024-09-03 16:34:24 +00:00
parent 7e207b7e93
commit ee85533bd1
3 changed files with 29 additions and 13 deletions

View File

@@ -24,7 +24,8 @@ const h_all = {
}
const server = createServer((rq, rx) => {
rq.method !== undefined && resp[rq.method] !== undefined && (new URL(`http://${config.host}:${config.port}${rq.url}`)).pathname === '/' ? resp[rq.method](rx) : rx.writeHead(400)
const handler = resp[rq.method ?? '']
handler !== undefined && (new URL(`http://${config.host}:${config.port}${rq.url}`)).pathname === '/' ? handler(rx) : rx.writeHead(400)
rx.end(() => void console.log('%s %d %s %s', (new Date()).toISOString(), rx.statusCode, rq.method, rq.url))
})
server.listen(config.port, config.host, () => void console.log(`Server started at http://${config.host}:${config.port} for ${config.filename}`))