Skip to content

Commit

Permalink
fix: fix rootProtoManager.registerRootProto
Browse files Browse the repository at this point in the history
not change the params order
  • Loading branch information
killagu committed Aug 17, 2022
1 parent 00a4848 commit f416ed7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion plugin/controller/lib/RootProtoManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export class RootProtoManager {
// <method, GetRootProtoCallback[]>
protoMap: Map<string, GetRootProtoCallback[]> = 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);
}
Expand Down
4 changes: 2 additions & 2 deletions plugin/controller/lib/impl/http/HTTPMethodRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '');
}
}

0 comments on commit f416ed7

Please sign in to comment.