Sha256: 9bca412f5fec2b288f677a04484996bb86b83caf896010f015aecb28449dca56

Contents?: true

Size: 1.11 KB

Versions: 32

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env ruby

require 'pathname'
require 'loggability'
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' )
		$SAFE = 1
	end


	### Handle a request
	def handle( request )
		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

end # class RequestDumper

Loggability.level = :debug
Loggability[ Inversion ].level = :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

32 entries across 32 versions & 1 rubygems

Version Path
mongrel2-0.48.0 examples/request-dumper.rb
mongrel2-0.47.0 examples/request-dumper.rb
mongrel2-0.46.0 examples/request-dumper.rb
mongrel2-0.45.1 examples/request-dumper.rb
mongrel2-0.45.0 examples/request-dumper.rb
mongrel2-0.44.0 examples/request-dumper.rb
mongrel2-0.43.2 examples/request-dumper.rb
mongrel2-0.43.0 examples/request-dumper.rb
mongrel2-0.42.0 examples/request-dumper.rb
mongrel2-0.42.0.pre.410 examples/request-dumper.rb
mongrel2-0.41.0 examples/request-dumper.rb
mongrel2-0.40.0 examples/request-dumper.rb
mongrel2-0.39.0 examples/request-dumper.rb
mongrel2-0.38.0 examples/request-dumper.rb
mongrel2-0.37.0 examples/request-dumper.rb
mongrel2-0.36.0 examples/request-dumper.rb
mongrel2-0.35.0 examples/request-dumper.rb
mongrel2-0.34.1.pre.357 examples/request-dumper.rb
mongrel2-0.34.0 examples/request-dumper.rb
mongrel2-0.33.0 examples/request-dumper.rb