framework: fix 404 handler

This commit is contained in:
undefined committed 2024-07-18 20:08:55 +08:00
1 parent 192efceb59
commit 17ebdea6b2
2 files changed
+7 -9

No files matched your search

+2 -2
View File
@@ -27,8 +27,8 @@
"@types/koa": "^2.15.0",
"@types/koa-compress": "^4.0.6",
"@types/koa-router": "^7.4.8",
"@types/lodash": "^4.17.6",
"@types/lodash": "^4.17.7",
"@types/saslprep": "^1.0.3",
"@types/ws": "^8.5.10"
"@types/ws": "^8.5.11"
}
}
+5 -7
View File
@@ -393,19 +393,17 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
}
this.router.use((c, next) => executeMiddlewareStack(c, [
...this.handlerLayers,
{
name: '404',
func: async (t: any, n) => {
await n();
if (!t.handler) this.handleHttp(t, NotFoundHandler, () => true);
},
},
{ name: 'logic', func: next },
]).catch(console.error));
this.server.use((c) => executeMiddlewareStack(c, [
...this.serverLayers,
{ name: 'routes', func: router.routes() },
{ name: 'methods', func: router.allowedMethods() },
...this.handlerLayers,
{
name: '404',
func: (t) => this.handleHttp(t, NotFoundHandler, () => true),
},
]));
this.addLayer('base', base(logger, this.config.xff, this.config.xhost));
wsServer.on('connection', async (socket, request) => {