Skip to content

Conversation

davidmjadams
Copy link
Collaborator

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 and others added 30 commits November 12, 2013 11:32
Adding passing test for returning responses in subfolders
really using github issues for that :)
Fixing default cors settings
Support the use of // in http:// and URI's in JSON
adding correct headers in CORS reponses, plus passing test
To make sure the codebase gets a little more consitency I setup jshint
and made some basic style fixes
inside new RegEx a . needs to be \\. or it will match like a . in / /
this allows logging the real filename which matched, instead of
constructing it, which make logging the name for query params work.

FIXES #15
inject filename in the httpObject
before the error was just hidden now it is logged when he sanatization
of the content fails, this is especially important for JSON since it
needs to be parseable to be returned by canned otherwise just false is
returned

RESOLVES #4
Needed to wrap commands in code tags
initially the plan obviously was to use id as the special name, but now
canned is using any as the keyword. So naming the files in example
```id.get.json``` is just wrong, to make them available via ```curl
localhost:3000/comment/1``` they need to be named ```any.get.json``` and
accordingly ```any.put.json```.

This causes confusion as seen in #20
sideshowcoder and others added 12 commits February 13, 2014 14:45
Aarrrgggh! Forgot those pesky quotes.
Fixed contentType header examples
Add support for empty files, returns status code 204 by default
Thanks to jkjustjoshing for that, awesome!
As pointed out in #37 this file should not be here and must have been commited by accident.

fixes #37
use either the 0.10 or 0.11 branch but use the latest versions for both
This is the first step to support windows since this will make moving
the query to the file possible.

You can now create multiple files with a number attached to the end of
the name. Currently the first file, according to file listing, will be
picked, this is WIP so and it should be a random pick.
this is the first step towards supporting get parameters in the file
header. Files will match even when extended with another . seperated
part in the name like

```
_action.verb.type.1
```

work towards issue #19
@sideshowcoder
Copy link
Owner

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
Copy link
Owner

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

@davidmjadams
Copy link
Collaborator Author

Great, glad it's useful.

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

Adds the ability to switch response payload based on request data. This can be either payload or header data
README.md Outdated
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind fixing the formatting? The other parts of the readme are formatted with 80chars per line, I can do it as well post merge but want to keep the Readme "clean"

@sideshowcoder
Copy link
Owner

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
Copy link
Contributor

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.

Test combining status code and repsonse body options.
Update README to document how to combine them.
Update contributors list
@dadams-sessiondigital
Copy link
Contributor

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 added a commit that referenced this pull request Nov 19, 2014
Variable response from request data
@sideshowcoder sideshowcoder merged commit 60c9bef into sideshowcoder:master Nov 19, 2014
@sideshowcoder
Copy link
Owner

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
Copy link
Contributor

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:
#39 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants