mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
framework: fix 404 handler
This commit is contained in:
2 files changed
+7
-9
No files matched your search
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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) => {
|
||||
|
||||
Reference in new issue
Block a user