evil-proxy
evil-proxy copied to clipboard
Simple helpers for stubbing a proxied server
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
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