Class: Proxie::Server
- Inherits:
-
Object
- Object
- Proxie::Server
- Defined in:
- lib/proxie/server.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(port = 8080, args = {}) ⇒ Server
constructor
Initialize server instance Options: :default => true Skip static filess like images, stylesheets, swf, etc :html => true Skip if html in body :js => true Skip javascripts.
-
#start ⇒ Object
Start proxy server.
-
#stop ⇒ Object
Stop proxy server.
Constructor Details
#initialize(port = 8080, args = {}) ⇒ Server
Initialize server instance Options:
:default => true Skip static filess like images, stylesheets, swf, etc
:html => true Skip if html in body
:js => true Skip javascripts
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/proxie/server.rb', line 12 def initialize(port=8080, args={}) @options = { :default => args[:default] || true, :js => args[:js] || true, :images => args[:images] || true } @server = WEBrick::HTTPProxyServer.new( :Port => port, :AccessLog => [], :ProxyContentHandler => Proc.new { |req, resp| process(req, resp) } ) end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/proxie/server.rb', line 5 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/proxie/server.rb', line 4 def @options end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/proxie/server.rb', line 3 def port @port end |
Instance Method Details
#start ⇒ Object
Start proxy server
34 35 36 37 |
# File 'lib/proxie/server.rb', line 34 def start raise RuntimeError, 'Logger is not defined!' if @logger.nil? @server.start end |
#stop ⇒ Object
Stop proxy server
40 41 42 |
# File 'lib/proxie/server.rb', line 40 def stop @server.shutdown end |