Sha256: 0911afa578a1b521b0072cf2c74e8ac8db939599eedf071e6d8941edc68ee3fd
Contents?: true
Size: 1.22 KB
Versions: 21
Compression:
Stored size: 1.22 KB
Contents
#!/usr/bin/env ruby require 'pathname' require 'logger' require 'mongrel2/config' require 'mongrel2/handler' require 'inversion' # A handler that just dumps the request it gets from Mongrel2 class RequestDumper < Mongrel2::Handler TEMPLATE_DIR = Pathname( __FILE__ ).dirname Inversion::Template.configure( :template_paths => [TEMPLATE_DIR] ) ### Pre-load the template before running. def initialize( * ) super @template = Inversion::Template.load( 'request-dumper.tmpl' ) end ### Handle a request def handle( request ) Thread.new do Thread.current.abort_on_exception = true $SAFE = 1 template = @template.dup response = request.response template.request = request template.title = "Ruby-Mongrel2 Request Dumper" template.safelevel = $SAFE response.status = 200 response.headers.content_type = 'text/html' response.puts( template ) response end.value end end # class RequestDumper Mongrel2.log.level = $DEBUG ? Logger::DEBUG : Logger::INFO Inversion.log.level = Logger::INFO # Point to the config database, which will cause the handler to use # its ID to look up its own socket info. Mongrel2::Config.configure( :configdb => 'examples.sqlite' ) RequestDumper.run( 'request-dumper' )
Version data entries
21 entries across 21 versions & 1 rubygems