Ghislain MARY
6/10/2005 10:26:00 PM
Hi,
mitchell a écrit :
> Instead of using an index.html, index.rhtml, index.cgi, etc. as the
> default page to load on localhost:[port], I was wondering if it was
> possible to load a servlet instead (i.e. '/index'). I have looked at
> the WEBrick source, but could not figure out how to do this (even like
> trying to execute a request or response).
>
> Any help would be greatly appreciated.
>
I am not sure I really understood what you want to do but I think you
can do something like:
require 'webrick'
svr = WEBrick::HTTPServer.new(
:Port => 8080,
:BindAddress => 'localhost'
)
svr.mount_proc('/') { |req, res|
res.body = "This is not the default index!"
res['content-type'] = "text/plain"
}
trap("INT") { svr.shutdown }
svr.start
Or you can mount a servlet instead of a proc...
HTH
Ghislain