diff --git a/plugin/controller/lib/RootProtoManager.ts b/plugin/controller/lib/RootProtoManager.ts index d4db89b6..eac1cc2c 100644 --- a/plugin/controller/lib/RootProtoManager.ts +++ b/plugin/controller/lib/RootProtoManager.ts @@ -8,7 +8,8 @@ export class RootProtoManager { // protoMap: Map = new Map(); - registerRootProto(method: string, host: string, cb: GetRootProtoCallback) { + registerRootProto(method: string, cb: GetRootProtoCallback, host: string) { + host = host || ''; const cbList = MapUtil.getOrStore(this.protoMap, method + host, []); cbList.push(cb); } diff --git a/plugin/controller/lib/impl/http/HTTPMethodRegister.ts b/plugin/controller/lib/impl/http/HTTPMethodRegister.ts index 17e7827b..c2ae7f36 100644 --- a/plugin/controller/lib/impl/http/HTTPMethodRegister.ts +++ b/plugin/controller/lib/impl/http/HTTPMethodRegister.ts @@ -168,10 +168,10 @@ export class HTTPMethodRegister { const regExp = pathToRegexp(methodRealPath, { sensitive: true, }); - rootProtoManager.registerRootProto(this.methodMeta.method, host || '', (ctx: EggContext) => { + rootProtoManager.registerRootProto(this.methodMeta.method, (ctx: EggContext) => { if (regExp.test(ctx.path)) { return this.proto; } - }); + }, host || ''); } }