Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问是否可以动态改动中间件的config呢? #56

Open
jebberwocky opened this issue Jan 26, 2018 · 3 comments
Open

请问是否可以动态改动中间件的config呢? #56

jebberwocky opened this issue Jan 26, 2018 · 3 comments

Comments

@jebberwocky
Copy link

因为遇到了每个request可能会用不同config的需求, 想请问是否可以动态改动中间件的config呢?

@jebberwocky
Copy link
Author

hack了code
Basic.prototype.done = function (handler) { var self = this; var payment = self.payment; return function (req, res, next) { if(req.wxpayconfig){ payment = new Payment(req.wxpayconfig); }

是否更好方法 ?

jebberwocky pushed a commit to jebberwocky/wechat-pay that referenced this issue Jan 26, 2018
@supersheep
Copy link
Owner

可以在middleware外套一层,来根据不同的请求上下文来堆middleware传递不同的config

@jinceon
Copy link

jinceon commented Apr 24, 2018

很强,我也遇到了这样的问题。
也是自己用hack的方式解决的。
但总觉得自己hack的方式很丑陋。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants