Class: EvilProxy::HTTPProxyServer
- Inherits:
-
WEBrick::HTTPProxyServer
- Object
- WEBrick::HTTPProxyServer
- EvilProxy::HTTPProxyServer
show all
- Defined in:
- lib/evil-proxy/httpproxy.rb
Constant Summary
collapse
- VALID_CALBACKS =
Array.new
- DEFAULT_CALLBACKS =
Hash.new
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config = {}, default = WEBrick::Config::HTTP) ⇒ HTTPProxyServer
10
11
12
13
14
|
# File 'lib/evil-proxy/httpproxy.rb', line 10
def initialize config = {}, default = WEBrick::Config::HTTP
initialize_callbacks config
fire :when_initialize, config, default
super
end
|
Instance Attribute Details
#callbacks ⇒ Object
Returns the value of attribute callbacks.
5
6
7
|
# File 'lib/evil-proxy/httpproxy.rb', line 5
def callbacks
@callbacks
end
|
Instance Method Details
#fire(key, *args) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/evil-proxy/httpproxy.rb', line 25
def fire key, *args
return unless @callbacks[key]
@callbacks[key].each do |callback|
instance_exec *args, &callback
end
end
|
#service(req, res) ⇒ Object
32
33
34
35
36
|
# File 'lib/evil-proxy/httpproxy.rb', line 32
def service req, res
fire :before_request, req
super
fire :before_response, req, res
end
|
#start ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/evil-proxy/httpproxy.rb', line 16
def start
begin
fire :when_start
super
ensure
fire :when_shutdown
end
end
|