sideshowcoder / canned

Server to respond with fake API responses, by using a directory of files for finding out what to say!
213 stars 46 forks source link

Iterate through all types and subtypes specified in the HTTP 'Accept' header #100

Closed CheungJ closed 8 years ago

CheungJ commented 8 years ago

The HTTP Accept header is a mechanism for the client to tell the server which media types are acceptable for the response.

Canned only checks the first subtype in the Accept header, but if a file does not exist with the first subtype, it does not attempt to check for a file matching the following subtypes.

sideshowcoder commented 8 years ago

This is true and so far has been by design, the reason being that as canned from my side has been used for testing I wanted the matching to be rather strict, as Accept headers are something notoriously handled in odd ways except the bare minimum. I can see the reason so why one would like it to be less strict, if possible even resemble different kind of backends (aka Rails does different things than Spring etc.) I'm happy to accept PRs changing this behaviour but would encourage it to be behind a command line option if at all possible.

CheungJ commented 8 years ago

I've created a PR for a "dumb" version of this issue: https://github.com/sideshowcoder/canned/pull/103

sideshowcoder commented 8 years ago

Awesome thanks for your work, I'm currently at a conference so I can't review but I will as soon as I'm back on Thursday. Thanks again cheers!

CheungJ commented 8 years ago

Cool, thanks! Enjoy the conference! :)

sideshowcoder commented 8 years ago

Thanks this is now available in 0.3.9! Great work!

CheungJ commented 8 years ago

Great! Thanks! I plan to contribute more in future.

sideshowcoder commented 8 years ago

Happy to hear! feel free to contact me on twitter https://twitter.com/ischi for quick things or we can jump into the gitter chat if need be 👍