mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: use bail to traigger route events
This commit is contained in:
1 parent
bdf2d972cd
commit
fd2ac84535
2 files changed
+10
-6
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.26.20",
|
"version": "2.26.21",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -665,17 +665,21 @@ async function handle(ctx, HandlerClass, checker) {
|
|||||||
throw new MethodNotAllowedError(method);
|
throw new MethodNotAllowedError(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
await bus.serial('handler/init', h);
|
await bus.bail('handler/init', h);
|
||||||
await bus.serial(`handler/before-prepare/${HandlerClass.name.replace(/Handler$/, '')}`, h);
|
await bus.bail(`handler/before-prepare/${HandlerClass.name.replace(/Handler$/, '')}`, h);
|
||||||
|
await bus.bail('handler/before-prepare', h);
|
||||||
if (h._prepare) await h._prepare(args);
|
if (h._prepare) await h._prepare(args);
|
||||||
if (h.prepare) await h.prepare(args);
|
if (h.prepare) await h.prepare(args);
|
||||||
await bus.serial(`handler/before/${HandlerClass.name.replace(/Handler$/, '')}`, h);
|
await bus.bail(`handler/before/${HandlerClass.name.replace(/Handler$/, '')}`, h);
|
||||||
|
await bus.bail('handler/before', h);
|
||||||
if (h[method]) await h[method](args);
|
if (h[method]) await h[method](args);
|
||||||
if (operation) await h[`post${operation}`](args);
|
if (operation) await h[`post${operation}`](args);
|
||||||
await bus.serial(`handler/after/${HandlerClass.name.replace(/Handler$/, '')}`, h);
|
await bus.bail(`handler/after/${HandlerClass.name.replace(/Handler$/, '')}`, h);
|
||||||
|
await bus.bail('handler/after', h);
|
||||||
if (h.cleanup) await h.cleanup(args);
|
if (h.cleanup) await h.cleanup(args);
|
||||||
if (h.finish) await h.finish(args);
|
if (h.finish) await h.finish(args);
|
||||||
await bus.serial(`handler/finish/${HandlerClass.name.replace(/Handler$/, '')}`, h);
|
await bus.bail(`handler/finish/${HandlerClass.name.replace(/Handler$/, '')}`, h);
|
||||||
|
await bus.bail('handler/finish', h);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
await h.onerror(e);
|
await h.onerror(e);
|
||||||
|
|||||||
Reference in new issue
Block a user