Class: RightSpeed::Handler
- Inherits:
-
Object
- Object
- RightSpeed::Handler
- Defined in:
- lib/right_speed/handler.rb
Defined Under Namespace
Classes: Client, Request, Response, Session
Instance Method Summary collapse
-
#initialize(app) ⇒ Handler
constructor
A new instance of Handler.
- #process(session, client, request) ⇒ Object
- #session(conn) ⇒ Object
Constructor Details
#initialize(app) ⇒ Handler
Returns a new instance of Handler.
13 14 15 |
# File 'lib/right_speed/handler.rb', line 13 def initialize(app) @app = app end |
Instance Method Details
#process(session, client, request) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/right_speed/handler.rb', line 21 def process(session, client, request) # https://github.com/rack/rack/blob/master/SPEC.rdoc env = { # TODO: replace the keys using constants: https://github.com/rack/rack/blob/master/lib/rack.rb 'HTTP_VERSION' => request.http_version, 'PATH_INFO' => request.path_info, 'QUERY_STRING' => request.query_string || "", 'REMOTE_ADDR' => client.addr, 'REQUEST_METHOD' => request.http_method, 'REQUEST_PATH' => request.path_info, 'REQUEST_URI' => request.request_uri, 'SCRIPT_NAME' => "", 'SERVER_NAME' => client.server_addr, 'SERVER_PORT' => client.server_port.to_s, 'SERVER_PROTOCOL' => request.http_version, 'SERVER_SOFTWARE' => RightSpeed::SOFTWARE_NAME, **request.headers_in_env_style, ### Rack specific keys 'rack.version' => RightSpeed::RACK_VERSION, 'rack.url_scheme' => 'http', # http or https, depending on the request URL. 'rack.input' => request.body, # The input stream. 'rack.errors' => $stderr, # The error stream. 'rack.multithread' => true, 'rack.multiprocess' => false, 'rack.run_once' => false, 'rack.hijack?' => false, # https://github.com/rack/rack/blob/master/SPEC.rdoc#label-Hijacking ### Optional Rack keys ## 'rack.session' # A hash like interface for storing request session data. # The store must implement: # store(key, value) (aliased as []=); fetch(key, default = nil) (aliased as []); # delete(key); clear; to_hash (returning unfrozen Hash instance); 'rack.logger' => session.logger, # A common object interface for logging messages. # The object must implement: # info(message, &block),debug(message, &block),warn(message, &block),error(message, &block),fatal(message, &block) ## 'rack.multipart.buffer_size' # An Integer hint to the multipart parser as to what chunk size to use for reads and writes. ## 'rack.multipart.tempfile_factory' # An object responding to #call with two arguments, the filename and content_type given for the multipart form field, # and returning an IO-like object that responds to #<< and optionally #rewind. This factory will be used to instantiate # the tempfile for each multipart form file upload field, rather than the default class of Tempfile. } status, headers, body = @app.call(env) Response.new(http_version: request.http_version, status_code: status, headers: headers, body: body) end |