Does nginx support such a function, that is, can the content of reply be modified?
For example, the content returned by the interface at the beginning is like this
"data" : {
"totalAmount" : 49, // 用户累积所中金额
"remainingCount" : 3 // 当天剩余抽奖次数
}
A new attribute was added at the end--Total number of draws
, so I wanted to change the previous remainingCount
to a more appropriate todayRemainingCount
"todayRemainingCount" : 3 // 当天剩余抽奖次数
"totalRemainingCount" : 10 // 总剩余抽奖次数
However, during the online process, the server comes online first, and then H5 comes online. Therefore, during this period, H5 will not be able to parse remainingCount
, affecting the normal online business logic.
So I want to do some temporary processing through nginx
during this period to make the upgrade smooth, such as parsing the server interface to automatically create a remainingCount
attribute based on todayRemainingCount
This is compatible with the old interface as shown below
"todayRemainingCount" : 3 // 当天剩余抽奖次数
"remainingCount" : 3 // 当天剩余抽奖次数 兼容旧接口
"totalRemainingCount" : 10 // 总剩余抽奖次数
Wait until H5 goes online before canceling this temporary restriction.
可以,看看 https://openresty.org/en/
你这种需求还是用程序作判断处理,或者多加个开关之类的比较好吧。
线上的 nginx 也不会随便改配置。
看你的需求,接口直接同时输出remainingCount和todayRemainingCount两项就可以了啊,调取接口的不管用哪个都能取到值,等你都部署好了之后再把接口返回的remainingCount去掉就行了
同事给了一个解决方案。
这是典型的接口模型该考虑的兼容。 不建议放到nginx上。比如:
还是在业务层做处理吧,不建议修改nginx