WEBrick allows you to be lazy. If your need is trivial and can be expressed in a simple Proc or a block, then you don't have to
bother with subclassing AbstractServlet.
start_webrick {|server|
server.mount_proc('/myblock') {|req, resp|
resp.body = 'a block mounted at #{req.script_name}'
}
my_wonderful_proc = Proc.new {|req, resp|
resp.body = 'my wonderful proc mounted at #{req.script_name}'
}
server.mount_proc('/myproc', my_wonderful_proc)
server.mount('/myprochandler',
HTTPServlet::ProcHandler.new(my_wonderful_proc))
}
Output:
dede:~$ w3m -dump http://localhost:8080/myblock a block mounted at /myblock dede:~$ w3m -dump http://localhost:8080/myproc my wonderful proc mounted at /myproc dede:~$ w3m -dump http://localhost:8080/myprochandler my wonderful proc mounted at /myprochandler