Class: Chimp::ChimpDaemon::GenericServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/right_chimp/daemon/ChimpDaemon.rb

Overview

GenericServlet – servlet superclass

Direct Known Subclasses

AdminServlet, DisplayServlet, GroupServlet, JobServlet

Instance Method Summary collapse

Instance Method Details

#get_id(req) ⇒ Object



288
289
290
291
292
# File 'lib/right_chimp/daemon/ChimpDaemon.rb', line 288

def get_id(req)
  uri_parts = req.request_uri.path.split('/')
  id = uri_parts[-2]
  return id
end

#get_job_uuid(req) ⇒ Object



294
295
296
297
298
# File 'lib/right_chimp/daemon/ChimpDaemon.rb', line 294

def get_job_uuid(req)
  string = req.body.scan(/job_uuid: .{6}/).last
  job_uuid = string.scan(/ (.{6})/).last.last
  return job_uuid
end

#get_payload(req) ⇒ Object

Get the body of the request– assume YAML



302
303
304
305
306
307
308
# File 'lib/right_chimp/daemon/ChimpDaemon.rb', line 302

def get_payload(req)
  begin
    return YAML::load(req.body)
  rescue StandardError => ex
    return nil
  end
end

#get_verb(req) ⇒ Object

get_verb get_id get_payload



284
285
286
# File 'lib/right_chimp/daemon/ChimpDaemon.rb', line 284

def get_verb(req)
  r = req.request_uri.path.split('/')[2]
end