Make the function, which decides whether to apply mocking, configurable
iPirat opened this issue · comments
Make the function, which decides whether to apply mocking, configurable
a la
.config({
mockDataPath: '/mock_data',
apiPath: '/api',
doMock: function(){
var myresult = /* implement some custom check */;
return myresult;
}
});
the default should be the "old" behaviour
Ah! Awesome idea!! I'll include that in the next version.
It's now a step closer, you can override shouldReplace
, replacePath
and isMocking
. The first two are a bit specific to this implementation (replace /api with /mock_data paths) so I'm thinking about how to make it cleaner. It's hard to make it more dynamic without it turning into "why not just make your own httpInterceptor?". Need to write docs for this though.
After several attempts it's just too dependent on everything else. It's not really possible to configure just one part without changing everything else. So we're back at just configuring the paths, but I've added a Q in the FAQ that shows how you can create your own httpInterceptor
which is what apiMock
does.