我想使用ng-apimock模拟为每种情况修改一个值的设置文件。这样一来,我不必在多个模拟JSON文件中创建我不想更改的所有设置的副本。我期望能够使用Express中间件来做到这一点。
let featureScenarioWriter = function (req, res, next) {
console.log("The request:" + req);
//check request is for the settings file
//load the settings file and modify the key\value matching what is in the response
//set the response to be the whole settings file with a single value changed
next();
};
app.set('port', 3000);
// process the api calls through ng-apimock
app.use(require('ng-apimock/lib/utils').ngApimockRequest);
// serve the mocking interface for local development
app.use('/mocking', express.static('./.tmp/ngApimock'));
app.use(featureScenarioWriter);
但是,没有任何请求到达featureScenarioWriter
函数。我认为这是因为响应以ngApimockRequest结尾。但是它们包括在their examples中使用中间件。
我想念什么吗?作为方案的一部分,我还有另一种方法可以更改文件中的一个值吗?
谢谢