lib/dripdrop/handlers/http.rb in dripdrop-0.6.0 vs lib/dripdrop/handlers/http.rb in dripdrop-0.7.1

- old
+ new

@@ -69,17 +69,19 @@ 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 '/' do + map uri_path do run HTTPApp.new(msg_format,&block) end end rescue Exception => e - puts "Error in Thin server: #{e.message}\n#{e.backtrace.join("\n")}" + $stderr.write "Error in Thin server: #{e.message}\n#{e.backtrace.join("\n")}" end end end class HTTPClientHandler < BaseHandler @@ -92,12 +94,14 @@ end def send_message(message,&block) dd_message = dd_messagify(message) if dd_message.class == DripDrop::Message + uri_path = @uri.path.empty? ? '/' : @uri.path + req = EM::Protocols::HttpClient.request( :host => @uri.host, :port => @uri.port, - :request => '/', :verb => 'POST', + :request => uri_path, :verb => 'POST', :contenttype => 'application/json', :content => dd_message.encode_json ) req.callback do |response| block.call(DripDrop::Message.decode_json(response[:content]))