Module: Scales::Server::Dispatch::Request

Defined in:
lib/scales-server/dispatch/request.rb

Class Method Summary collapse

Class Method Details

.to_job(id, env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/scales-server/dispatch/request.rb', line 7

def to_job(id, env)
  scales_variables  = { 'scales.id' => id }
  request_variables = env.dup.keep_if{ |key, value| [
    'REQUEST_METHOD',
    'PATH_INFO',
    'QUERY_STRING',
    'SERVER_NAME',
    'SERVER_PORT'
  ].include?(key) }
  http_variables    = env.dup.keep_if{ |key, value| key.match /^HTTP_/  }
  rack_variables    = {
    'rack.version'      => env['rack.version'],
    'rack.url_scheme'   => env['rack.url_scheme'],
    'rack.input'        => env['rack.input'].string
  }
  scales_variables.merge(request_variables).merge(http_variables).merge(rack_variables)
end