I think this is the key. Something like this is the real focus. The implementation could be much much simpler. E.g.
````
var doMockOverride = !!req.apiMock;
if (req && (apiMock.isMocking() || doMockOverride) && apiMock.shouldReplace(req)) {
...
````