Class: Ruku::Clients::Web::AjaxServlet

Inherits:
HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/ruku/clients/web.rb

Instance Method Summary collapse

Instance Method Details

#do_GET(req, resp) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ruku/clients/web.rb', line 52

def do_GET(req, resp)
  @remote_manager ||= Remotes.new
  @remote_manager.load

  cmd = req.query['command']
  action = req.query['action']
  if cmd
    resp.body = run_command(cmd, req.query['host'])
    raise HTTPStatus::OK
  elsif action
    resp.body = perform_action(action, req.query['data'])
    raise HTTPStatus::OK
  else
    raise HTTPStatus::PreconditionFailed.new("Missing parameter: 'command' or 'action'")
  end
end