How to assign a rack handler

Rackup successfully launches any Rack application through the default Rack handler. eg:.

class RackApp  
  def call(environment)    
  [
    '200', 
    {'Content-Type' => 'text/html'}, 
    ["Hello world"]
  ]
  end 
end
run RackApp.new

But when starting the last line instead of "Rack", the built-in CGI handler "NoMethodError at / undefined method" call "for nil: NilClass" <

Rack::Handler::CGI.run RackApp.new

The same objection arises for other built-in Rack handlers. for example Rack :: Handler :: Thin, Rack :: Handler :: FastCGI, even Rack :: Handler :: WEBrick (which is the handler that will select above in default mode).

What is the correct syntax here?

+5
source share
2 answers

rackup . Rack::Handler::XXX.run , rackup (CGI , ).

run RackApp.new

Rack::Handler::CGI.run RackApp.new

rackup . . Rack::Handler::CGI.run RackApp.new , , Ruby. CGI , CGI script ( rackup). "rackup" , . , NoMethodError, .

Rack::Handler::Thin , , Thin -, RackApp, 8080 ( 9292). Thin (, Ctrl-C) (Mongrel Webrick) 9292, , NoMethodError.

"config.ru" Ruby script, rawn, , rawn. ( , ruby -rrack config.ru). CGI , Thin Thin, .

, -s, . rackup -s thin Thin ( 9292). rackup -s cgi, - - html .

CGI

CGI, . CGI script, CGI. script, Rack::Handler::CGI.run , config.ru ( require 'rack').

script, rackup config.ru. , CGI

+7

All Articles