Class: Eye::Http
Constant Summary collapse
- Router =
Cuba.new do def json(result) res.headers['Content-Type'] = 'application/json; charset=utf-8' res.write({ result: result }.to_json) end on root do res.write Eye::ABOUT end on "api/info", param("filter") do |filter| json Eye::Control.command(:info_data, filter) end [:start, :stop, :restart, :delete, :unmonitor, :monitor].each do |act| on put, "api/#{act}", param("filter") do |filter| json Eye::Control.command(act, filter) end end end
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(host, port) ⇒ Http
constructor
A new instance of Http.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/eye/http.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/eye/http.rb', line 11 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
11 12 13 |
# File 'lib/eye/http.rb', line 11 def server @server end |
Instance Method Details
#start ⇒ Object
19 20 21 22 |
# File 'lib/eye/http.rb', line 19 def start stop @server = Reel::Rack::Server.supervise(@router, :Host => @host, :Port => port) end |
#stop ⇒ Object
24 25 26 27 28 29 |
# File 'lib/eye/http.rb', line 24 def stop if @server @server.terminate @server = nil end end |