-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support other Content-Types #31
Comments
Hey @turicas thanks for the suggestion. I think it's a sensible one, not entirely how I'd approach implementing it though. I was a bit hesitant because I don't want to expand Interfake's scope too much but I can see how it could be useful, and fairly simple to change the response format. For msgpack especially, it might be possible to simply use this encoder/decoder, msgpack-js as some kind of middleware for the body. I'm all for it! You're welcome to give it a go if you like, but for now I'll put a |
@basicallydan, first of all, thanks! :-) One possible solution is to create a http-proxy on top of Interfake that does all the content-type thing, so we don't need to modify Interfake internals. Unfortunately by now I don't enough time and knowledge on NodeJS/Express to do it quickly. |
@turicas No prob! Would that http-proxy module work for the case you're talking about? It sounds like the data would need to be transformed, and it might be easy enough to do it within Interfake. If http-proxy can do it without changing how the data is stored in memory then it should be just a matter of detecting the accept header type and transforming it. Does that sound about right? |
Yep! The idea is to put on the proxy module the responsability on detecting the |
Hello,
I'd like to use interfake to simulate an API I'm implementing but I think I can't use more than one Content-Type for the same HTTP resource. In my case, I'd like to answer the same data but in different formats, depending on
Accept
header sent by client -- this is needed because some of my API clients use msgpack to serialize data and others simply use JSON.I've done a quick look into interfake's code but as I'm new to nodejs world, I didn't start implementing this feature by now, but I think we'll need to modify
expectationsLookup
andRoute.simpleHash
to implement this feature. What do you think?Note: thanks for writing this awesome project! :)
The text was updated successfully, but these errors were encountered: