Skip to content

Commit

Permalink
fix(webloader): remove routerArgs concat
Browse files Browse the repository at this point in the history
  • Loading branch information
yviscool committed Jun 25, 2019
1 parent ae3fa99 commit 9feb872
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/midway-web/src/loader/webLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class MidwayWebLoader extends EggLoader {
webRouter.path,
...methodMiddlwares,
this.generateController(`${controllerId}.${webRouter.method}`)
].concat(methodMiddlwares);
];

// apply controller from request context
newRouter[webRouter.requestMethod].apply(newRouter, routerArgs);
Expand Down Expand Up @@ -269,9 +269,7 @@ export class MidwayWebLoader extends EggLoader {
* @param controllerMapping like xxxController.index
*/
public generateController(controllerMapping: string) {
const mappingSplit = controllerMapping.split('.');
const controllerId = mappingSplit[0];
const methodName = mappingSplit[1];
const [controllerId, methodName] = controllerMapping.split('.');
return async (ctx, next) => {
const controller = await ctx.requestContext.getAsync(controllerId);
return controller[methodName].call(controller, ctx, next);
Expand Down

0 comments on commit 9feb872

Please sign in to comment.