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

Variable response from request data #39

Closed davidmjadams closed 9 years ago

davidmjadams commented 9 years ago

Hi,

I’ve added the ability to get variable responses from an endpoint, based on request data. This is something I personally need from canned. I usually end up needing this when working with anything more than a simple api.

Please feel free to close if it doesn’t fit with the goals of the project.

Thanks.

sideshowcoder commented 9 years ago

Thanks for that, from first looks its good! It's definitely functionality I feel is important and I've been working on something similar but didn't get to finish so thanks soo much for the PR. I will look over this asap

sideshowcoder commented 9 years ago

@hungrydavid do you mind rebasing so the history stays clean?

davidmjadams commented 9 years ago

Great, glad it's useful.

Sure, I'll rebase as soon as I get a chance - knew there was something I forgot!

sideshowcoder commented 9 years ago

This looks good to me. Sorry to be a little annoying about small things like semicolon and such, I can change those after merge as well. Also I'd like to see a test testing the combination of status and body features for the responses, I hope I don't have overlooked it if so sorry. Otherwise I think this is fine to merge thanks so much for your work! Feel free to add yourself to the Readme of Contributors.

dadams-sessiondigital commented 9 years ago

Not a problem at all about code style bits. I'll fix them up, always good to maintain a consistent style. You're right about the status/body test, that is something I've overlooked. I'll take a look at that as soon as I can - hopefully tomorrow.

dadams-sessiondigital commented 9 years ago

I've added the test combining the status and response options. It doesn't currently support varying status code per response - that would need a bit of a rewrite of the extractOptions method. I'm happy to take a look at this, but I won't have time for a little bit now.

Thanks for writing canned, it's a great tool. I've been searching for a suitable mock server for a while and it's definitely the best I've come across.

sideshowcoder commented 9 years ago

This looks good and very valuable to me! Thanks for the contribution. I'm always very excited to hear people are using canned. Would you be interested to add yourself to the Use cases page I just created?

dadams-sessiondigital commented 9 years ago

Glad to be able to help :) 

Yeah, sure. I’ll add something to the use cases in the next couple of days. Thanks.

— Sent from Mailbox

On Wed, Nov 19, 2014 at 6:53 PM, Philipp Fehre notifications@github.com wrote:

This looks good and very valuable to me! Thanks for the contribution. I'm always very excited to hear people are using canned. Would you be interested to add yourself to the Use cases page I just created?

Reply to this email directly or view it on GitHub: https://github.com/sideshowcoder/canned/pull/39#issuecomment-63692406