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 // 當(dāng)天剩余抽獎(jiǎng)次數(shù)
}
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 // 當(dāng)天剩余抽獎(jiǎng)次數(shù)
"totalRemainingCount" : 10 // 總剩余抽獎(jiǎng)次數(shù)
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 // 當(dāng)天剩余抽獎(jiǎng)次數(shù)
"remainingCount" : 3 // 當(dāng)天剩余抽獎(jiǎng)次數(shù) 兼容舊接口
"totalRemainingCount" : 10 // 總剩余抽獎(jiǎng)次數(shù)
Wait until H5 goes online before canceling this temporary restriction.
光陰似箭催人老,日月如移越少年。
Okay, take a look at https://openresty.org/en/
For your needs, it’s better to use a program to judge and handle it, or add an extra switch or something.
Online nginx will not change the configuration casually.
Depending on your needs, the interface can directly output both remainingCount and todayRemainingCount at the same time. No matter which interface you use to call the interface, you can get the value. After you have deployed everything, just remove the remainingCount returned by the interface
A colleague gave me a solution.
This is a typical interface model that should be considered for compatibility. It is not recommended to put it on nginx. For example:
public class Output {
private int todayRemaingCount;
private int totalRemaingCount;
// getter/setter methods;
// 下一個(gè)版本升級(jí),去掉此方法,預(yù)計(jì)在10.17。
@Deprecated
public int getRemainingCount() {
return todayRemaingCount;
}
}
It is better to do the processing at the business layer. It is not recommended to modify nginx