summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM. Hecker <apoc@sixserv.org>2014-04-29 22:19:51 +0200
committerM. Hecker <apoc@sixserv.org>2014-04-29 22:19:51 +0200
commit111c284f29dd728f6535ed05d1f2820fff02b78d (patch)
treec6861af4a2a29b05b17e607dcea9b8b14fc4ac09
parent98d6450f694f87f0bacd94dd20eee6cec67f7aaa (diff)
[webservice] add /ping test route
-rw-r--r--lib/rbot/core/webservice.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/rbot/core/webservice.rb b/lib/rbot/core/webservice.rb
index 0eb65522..21acf87d 100644
--- a/lib/rbot/core/webservice.rb
+++ b/lib/rbot/core/webservice.rb
@@ -28,6 +28,18 @@ class ::WebServiceUser < Irc::User
attr_accessor :response
end
+class PingServlet < WEBrick::HTTPServlet::AbstractServlet
+ def initialize(server, bot)
+ super server
+ @bot = bot
+ end
+
+ def do_GET(req, res)
+ res['Content-Type'] = 'text/plain'
+ res.body = "pong\r\n"
+ end
+end
+
class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
def initialize(server, bot)
super server
@@ -143,6 +155,7 @@ class WebServiceModule < CoreBotModule
@server = WEBrick::HTTPServer.new(opts)
debug 'webservice started: ' + opts.inspect
@server.mount('/dispatch', DispatchServlet, @bot)
+ @server.mount('/ping', PingServlet, @bot)
Thread.new { @server.start }
end