Sha256: e59bfcd0862b4ff6eeaa5b86cdf0e9a5430f1069942f3930f25a1b503772c460

Contents?: true

Size: 905 Bytes

Versions: 35

Compression:

Stored size: 905 Bytes

Contents

#!/usr/bin/env ruby

require 'loggability'
require 'mongrel2/config'
require 'mongrel2/handler'

# A dumb, dead-simple example that just returns a plaintext 'Hello' document.
class HelloWorldHandler < Mongrel2::Handler

	### The main method to override -- accepts requests and returns responses.
	def handle( request )
		response = request.response

		response.status = 200
		response.headers.content_type = 'text/plain'
		response.puts "Hello, world, it's #{Time.now}!"

		return response
	end

end # class HelloWorldHandler

configdb = ARGV.shift || 'examples.sqlite'

# Log to a file instead of STDERR for a bit more speed.
# Loggability.output_to( 'hello-world.log' )
Loggability.level = :debug

# 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: configdb )
HelloWorldHandler.run( 'helloworld-handler' )

Version data entries

35 entries across 35 versions & 1 rubygems

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