node-webot / co-wechat

Wechat for Koa
427 stars 91 forks source link

如何在handle中获取ctx上下文,现在只传递了一个message #30

Closed dcboy closed 7 years ago

dcboy commented 7 years ago
    // 业务逻辑处理
    const body = await handle(formatted);

这里handle 需要获取ctx

zuoye520 commented 7 years ago

@dcboy

我把源码稍微改动了一下,我是这么处理的。 const body = await handle(formatted, ctx); 前面接收 async(message, ctx) => { return '测试消息'; }

dcboy commented 7 years ago

router.all([path], async(ctx, next) => { return wechat('xxxx').middleware(controller[v].bind(null, ctx))(ctx, next); });

这样也可以,不改代码了

JacksonTian commented 7 years ago

我加上 ctx 作为第二个参数吧。

JacksonTian commented 7 years ago

发布了 2.2.0