Class: DripDrop::HTTPServerHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- DripDrop::HTTPServerHandler
- Defined in:
- lib/dripdrop/handlers/http.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(uri, opts = {}) ⇒ HTTPServerHandler
constructor
A new instance of HTTPServerHandler.
- #on_recv(msg_format = :dripdrop_json, &block) ⇒ Object
Constructor Details
#initialize(uri, opts = {}) ⇒ HTTPServerHandler
Returns a new instance of HTTPServerHandler.
62 63 64 65 66 |
# File 'lib/dripdrop/handlers/http.rb', line 62 def initialize(uri,opts={}) @uri = uri @address = uri.to_s @opts = opts end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
60 61 62 |
# File 'lib/dripdrop/handlers/http.rb', line 60 def address @address end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
60 61 62 |
# File 'lib/dripdrop/handlers/http.rb', line 60 def opts @opts end |
Instance Method Details
#on_recv(msg_format = :dripdrop_json, &block) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/dripdrop/handlers/http.rb', line 68 def on_recv(msg_format=:dripdrop_json,&block) #Thin's error handling only rescues stuff w/o a backtrace begin Thin::Logging.silent = true uri_path = @uri.path.empty? ? '/' : @uri.path Thin::Server.start(@uri.host, @uri.port) do map uri_path do run HTTPApp.new(msg_format,&block) end end rescue Exception => e $stderr.write "Error in Thin server: #{e.}\n#{e.backtrace.join("\n")}" end end |