Class: GThang::RackHandler
- Inherits:
-
Object
- Object
- GThang::RackHandler
- Defined in:
- lib/g_thang/rack_handler.rb
Constant Summary collapse
- StatusCodeMapping =
{ 200 => "OK", 400 => "Bad Request", 403 => "Forbidden", 405 => "Method Not Allowed", 411 => "Length Required", 500 => "Internal Server Error" }
- DefaultResponseHeaders =
{ "Connection" => "close", "Content-Type" => "text/html" }
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #handle_request ⇒ Object
-
#initialize(socket, app, port) ⇒ RackHandler
constructor
A new instance of RackHandler.
Constructor Details
#initialize(socket, app, port) ⇒ RackHandler
Returns a new instance of RackHandler.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/g_thang/rack_handler.rb', line 24 def initialize(socket, app, port) @socket = socket @app = app @env = { "GATEWAY_INTERFACE" => "CGI/1.1", "SCRIPT_NAME" => "", "SERVER_NAME" => Socket.gethostname, "SERVER_PORT" => port.to_s } end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
22 23 24 |
# File 'lib/g_thang/rack_handler.rb', line 22 def app @app end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
22 23 24 |
# File 'lib/g_thang/rack_handler.rb', line 22 def env @env end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
22 23 24 |
# File 'lib/g_thang/rack_handler.rb', line 22 def port @port end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
22 23 24 |
# File 'lib/g_thang/rack_handler.rb', line 22 def socket @socket end |
Instance Method Details
#handle_request ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/g_thang/rack_handler.rb', line 35 def handle_request return unless add_rack_variables_to_env return unless add_connection_info_to_env return unless add_request_line_info_to_env return unless add_headers_to_env send_response(app.call(env)) end |