gstroup / apimocker

node.js module to run a simple http server for mock service responses.
MIT License
280 stars 81 forks source link

Support 404 response on missing mockFile using switch #66

Closed aburmeis closed 8 years ago

aburmeis commented 8 years ago

A typical behaviour of REST servers is to return a not found state for unknown ids. This is currently hard to configure. By configuring a non existing base file for a web service with a switch (but of course with matching mock files for some switch values) the service returns a simple 404 in a non matching switch instead of throwing an error.

gstroup commented 8 years ago

Thanks for the pull request. Let me make sure I understand. So, in the current code, if there is a switch set up, but your request does not match a configured mock file, then you'll get an error? Is that right? But we should return a 404 in this case? I think that makes sense. I think other people have had problems with that poor error handling.

So, I think your change looks pretty good. Would you have time to add a test or two? Then I can more quickly accept the PR and publish a new version. Thanks again!

aburmeis commented 8 years ago

Right, the error handling is the problem. Expecting a 404 instead the app crashes. Sorry, adding a good test is not so easy for me as I am backend dev with very few JS experience.