-
Notifications
You must be signed in to change notification settings - Fork 158
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 for passthrough by default #80
Comments
Hmm, I think it should be possible with something like this: var server = new Pretender(function() {
// all handled routes here ...
this.get('/api/version', function(request) {
return [200, {}, JSON.stringify({ version: "123" })];
});
// add wildcards for all other routes and pass them through
this.get('/*youvegottacatchemall', this.passthrough);
this.post('/*youvegottacatchemall', this.passthrough);
this.put('/*youvegottacatchemall', this.passthrough);
this.delete('/*youvegottacatchemall', this.passthrough);
}); EDIT: as pointed out by @NLincoln below, in newer versions, the shorter path |
That did it! Not sure why though. I tried Leaving the issue open for now because it'd still be a nice feature to have, even though there does seem to be a workaround. |
I think it's because |
Closing, since @pangratz's solution is how you'd do this. |
Even though this is old, it's the top result for "pretender default passthrough", and a better solution I've found is similar to the one at the top, but instead of making the url |
2020 called to confirm that @NLincoln's solution still works. |
We needed to support hosts as well and ended up with this little hack..
may cover #210 too, depending on use-case |
Currently, there doesn't seem to be a way to only use Pretender for only a couple of specific paths, while allowing everything else to behave normally.
I'm trying to use Pretender to stub out data for one or two endpoints that aren't built out yet on the server. Since I do have a whole lot of other endpoints that are built out, I'd like to tell it to go ahead and treat all unhandled requests as passthroughs. Essentially, if I didn't tell it what to do for a path, let my server handle it.
The text was updated successfully, but these errors were encountered: