class DispatchServlet

Public Class Methods

new(server, bot) click to toggle source
Calls superclass method
# File lib/rbot/core/webservice.rb, line 371
def initialize(server, bot)
  super server
  @bot = bot
end

Public Instance Methods

dispatch(req, res) click to toggle source
# File lib/rbot/core/webservice.rb, line 376
def dispatch(req, res)
  res['Server'] = 'RBot Web Service (http://ruby-rbot.org/)'
  begin
    m = WebMessage.new(@bot, req, res)
    @bot.web_dispatcher.handle m
  rescue WEBrick::HTTPStatus::Unauthorized
    res.status = 401
    res['Content-Type'] = 'text/plain'
    res.body = 'Authentication Required!'
    error 'authentication error (wrong password)'
  rescue
    res.status = 500
    res['Content-Type'] = 'text/plain'
    res.body = "Error: %s\n" % [$!.to_s]
    error 'web dispatch error: ' + $!.to_s
    error $@.join("\n")
  end
end
do_GET(req, res) click to toggle source
# File lib/rbot/core/webservice.rb, line 395
def do_GET(req, res)
  dispatch(req, res)
end
do_POST(req, res) click to toggle source
# File lib/rbot/core/webservice.rb, line 399
def do_POST(req, res)
  dispatch(req, res)
end