Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (17 sloc) 513 Bytes

EM-Proxy

EventMachine Proxy DSL:

Simple port forwarding proxy

Proxy.start(:host => "0.0.0.0", :port => 80) do |conn|
  conn.server :srv, :host => "127.0.0.1", :port => 81

  # modify / process request stream
  conn.on_data do |data|
    p [:on_data, data]
    data
  end

  # modify / process response stream
  conn.on_response do |backend, resp|
    p [:on_response, backend, resp]
    resp
  end
end
Something went wrong with that request. Please try again.