Skip to content
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

Proxy Requests for Unknown Paths #56 #84

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

git-jiby-me
Copy link
Collaborator

  • can define proxy in options as a domain to forward requests with unknown path to
  • requests with unknown path will be forwarded to proxy domain, and response provided as mock

Request stream only should be consumed if we could find the path in
mock files, else don’t consume as the stream will be needed to proxy
the request.
@git-jiby-me
Copy link
Collaborator Author

@sideshowcoder everything works now, take a look at this, let me know if you have some comments. I need you help documenting this into README

@sideshowcoder
Copy link
Owner

Thanks for all your work :) I will look through it as soon as possible not gonna make it today but likely tomorrow. I have to think about a little I guess but first look thorugh looks very good :)

@git-jiby-me
Copy link
Collaborator Author

@sideshowcoder no problemo

@@ -295,6 +295,7 @@ Release History
---------------
Copy link
Owner

Choose a reason for hiding this comment

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

after the https://github.com/sideshowcoder/canned/blob/feature-56_proxy_request/README.md#variable-responses section you could add a new section to the README detailing how the proxy stuff works, this would need to contain some examples on how to use it with the commands to enter and the flow of a request through canned with a proxy enabled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sideshowcoder yep i will do that, but give me till this weekend, because i am travelling till wednesday

@sideshowcoder
Copy link
Owner

Looks very good! One thing I would suggest as a refactor is moving the proxy response into its own object, we already have the Response which gets returned and send back, maybe making a compatible ProxyResponse object which behaves the same way but uses the Proxy underneath would remove some of the more complicated pieces out of the main and would make them even more easily testable. What do you think?

@git-jiby-me
Copy link
Collaborator Author

@sideshowcoder well it would definitely makes sense, and i also like to do it, but i would propose to have a refactor PR, problems i see currently are

  • so much logic inside canned.js, we should split it up.
  • i don't see the current logic of reading all mock files each time a request comes up, we should read on init, and when something changes in the folder, would make it a lot cleaner, and will make it possible to better separate code.

I see that you already got a proposal to use promises, and you found its pros to not weight in for a change, i want to have another try at it, so lets keep this PR paused, and let me work on a proposal for refactor and then come back to this PR ?

Do you agree with my idea, because i would really like to make the code organised better and performant, before we do much stuff on additional features, i could make a spec, and then we can work our way up.

@sideshowcoder
Copy link
Owner

@git-jiby-me I'm happy to have this PR in with the small changes according to the comments if you are alright with that. Than we can refactor towards a better split. I fear that if we keep this on hold much is going to move and this is not going to be mergable anymore soon. What do you think about making the small changes + README and merge this and open a 2. PR for the refactor? Or are we already agreeing on this and I missread, if so sorry.

@git-jiby-me
Copy link
Collaborator Author

@sideshowcoder i am ok to go with the small changes, i will have them pushed by this week end 👍

@sideshowcoder
Copy link
Owner

Awesome!

@git-jiby-me
Copy link
Collaborator Author

@sideshowcoder i will add documentation some day soon, within this week

@git-jiby-me
Copy link
Collaborator Author

@sideshowcoder added documentation as well, have a look and let me know, if its good to merge

@sideshowcoder
Copy link
Owner

Just looked through it sorry for the slow response but it was a busy weekend. I think this now looks good to me! You might want to squash the commits before merging (http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) the workflow would be like

$ git rebase -i master
... change pick to squash for all but the first commit
... write a good commit message to describe the whole feature
$ git push origin feature-56_proxy_request -f

now when you reload the PR this should only have one commit in it. As there are many commits in this PR it makes it a little cleaner. If you need help feel free reach out and I can help! Thank you so much for all the work this has been on my list for long and it is a really nice implementation!

@git-jiby-me
Copy link
Collaborator Author

@sideshowcoder i kind of lost on this because of work, will get this done next week

@buzzdecafe
Copy link

bumping this PR since i could really use this feature. please lmk if there is any way i can help.

@sideshowcoder
Copy link
Owner

@buzzdecafe I guess the thing left is to confirm it works, rebase against master and thats it. I'm happy to merge probably after the weekend. I can take a look on monday but help is much appriciated to a) confirm it works, and b) rebase with current master.

@buzzdecafe
Copy link

@sideshowcoder After rebasing master onto that branch I am getting 71/73 test failures. 😄 Looks like there have been some API changes since this PR. So no, it doesn't work yet.

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.

3 participants