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 helpers for stubbing a proxied server #7

Open
jbodah opened this issue Jul 18, 2018 · 1 comment
Open

Simple helpers for stubbing a proxied server #7

jbodah opened this issue Jul 18, 2018 · 1 comment

Comments

@jbodah
Copy link

jbodah commented Jul 18, 2018

Hey, thanks for this repo! It's been really useful for stubbing out some JS files with local versions without having to do tons of data setup

Right now I'm doing something like the following to stub out some requests on a proxied host. I'd love to know if 1) there is an easier way to do this or 2) you'd be open to me adding some helpers to streamline this:

require 'evil-proxy'

proxy = EvilProxy::MITMProxyServer.new Port: 8080, MITMPattern: /my\.server\.com/

proxy.after_mitm do |req, res|
  # Hook into the created MITM server and prepend functionality to the GET handler
  @mitm_servers["my.server.com"].singleton_class.class_eval do
    def do_GET(req, res)
      if req.path =~ /some.*.file/
        res.body = "hello world"
      else
        super
      end
    end
  end
end

proxy.start
@jbodah
Copy link
Author

jbodah commented Jul 19, 2018

Riffed on this a bit here: https://github.com/jbodah/minion_rb#minion_rb. The implementation is a bit intrusive but it's functional and gets the point across

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

No branches or pull requests

1 participant