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

Simple HTTP Proxy #49

Merged
merged 11 commits into from
Feb 15, 2022
Merged

Simple HTTP Proxy #49

merged 11 commits into from
Feb 15, 2022

Conversation

Alexander-Ignition
Copy link
Collaborator

@Alexander-Ignition Alexander-Ignition commented Jan 9, 2022

Close: #40 #39

Catbird only supports direct requests to its host.

To do this, the CATBIRD_PROXY_URL environment variable is set. And she was also responsible for switching to recording mode. This confused the users.

In this MR, this variable has been split into 3

  • CATBIRD_RECORD_MODE to explicitly enable recording mode
  • CATBIRD_REDIRECT_URL to set the url to which direct requests will be redirected
  • CATBIRD_PROXY_ENABLED to enable proxying mode so that requests from different hosts can be redirected to a real server

@Alexander-Ignition Alexander-Ignition added the enhancement New feature or request label Jan 9, 2022
@Alexander-Ignition Alexander-Ignition added this to the HTTP Proxy milestone Jan 9, 2022
@Alexander-Ignition Alexander-Ignition self-assigned this Jan 9, 2022
@modestman
Copy link
Collaborator

@Alexander-Ignition Hi!
Write in more detail, what functionality does this PR add? And how to run the project in proxy mode?
I don't know anything about Vapor and Swift NIO, so I can only test if the added feature works.

@Alexander-Ignition
Copy link
Collaborator Author

@modestman I have updated the README and tests for the new feature.

For verification, you can run through Xcode with different environment variables set in the schema.

or you can run from the terminal with different environment variables

CATBIRD_PROXY_ENABLED=1 swift run catbird --package-path Packages/CatbirdApp

you can try to run requests via curl as in README

@Alexander-Ignition Alexander-Ignition changed the title [WIP]: Simple HTTP Proxy Simple HTTP Proxy Feb 13, 2022
README.md Outdated Show resolved Hide resolved

`CATBIRD_PROXY_URL` — If you specify this URL Catbird will run in write mode. In this mode, requests to Catbird will be redirected to the `CATBIRD_PROXY_URL`. Upon receipt of response from the server it will be written to the `CATBIRD_MOCKS_DIR` directory.
> Catbird supports proxying only HTTP requests. HTTPS requests are not supported!
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do you think, it is possible in the future to make a proxy for HTTPS endpoints, like Charles or Proxyman?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would be cool! But Vapor does not support configuring the server as a proxy. To do this, you would have to use SwiftNIO without Vapor. I haven't been able to make a working prototype yet

@Alexander-Ignition Alexander-Ignition merged commit b590424 into master Feb 15, 2022
@Alexander-Ignition Alexander-Ignition deleted the feature/proxy branch February 15, 2022 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP Proxy in read mode
2 participants