This post originated from an RSS feed registered with Ruby Buzz
by Red Handed.
Original Post: Holy Great CGI In Heaven!
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
I know this is a dead simple library, but I’ve been wanting this forever and just not getting around to it. Tanaka Akira presents webapp, a generic interface for writing server-neutral CGIs. Supports CGI, FastCGI,i WEBrick, mod_ruby and command-line interface. This goes in Hobix.
#!/path/to/ruby
require 'webapp'
WebApp do |webapp|
webapp.puts <<_END_
current time: #{Time.now}
pid: #{$$}
self: #{self.inspect}
request_method: #{webapp.request_method}
server_name: #{webapp.server_name}
server_port: #{webapp.server_port}
script_name: #{webapp.script_name}
path_info: #{webapp.path_info}
query_string: #{webapp.query_string}
server_protocol: #{webapp.server_protocol}
remote_addr: #{webapp.remote_addr}
content_type: #{webapp.content_type}
--- request headers ---
_END_
webapp.each_request_header do |k, v|
webapp.puts "#{k}: #{v}"
end
end
If you’re wondering why the documentation is so sparse, it’s because of all the delegators used in the WebApp class.