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