gstroup / apimocker

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

Add proxy option #35

Closed ztsmith closed 8 years ago

ztsmith commented 9 years ago

It would be great to have a function that allows any non-configured webservice endpoints to be forwarded to a proxy.

A possible use case might be if you only want to partially mock an API, and forward all non-mocked endpoints to the real API.

This looks relatively straight forward to implement, and I would be happy to submit a PR if there is interest.

One implementation question I have is - should we forward only for endpoints that are not configured, or also include endpoints where no switch value is matched?

gstroup commented 9 years ago

Yes, I've thought about adding a proxy option before, but never did. Mainly, I just wanted to keep this project simple. But it has grown up a bit now... if we can add a proxy option without tons of bloated code, then I think it would be a nice feature.

For your implementation question - my first impulse is to only forward requests for endpoints that are not configured.

Another feature along these lines, that we might want is to capture responses from the proxied (real) API. But that's another story, we could get in to later.

Thanks for your input!

gstroup commented 9 years ago

Not sure if you are working on this feature now... if so, you should pull from master again. I just merged in two other PRs. Thanks.