From: GOTOU Yuuzou Date: 2003-09-08T01:54:43+09:00 Subject: Re: initializing a servlet in WEBRick In message <200309071717.08089.fxn@hashref.com>, `Xavier Noria ' wrote: > On Sunday 07 September 2003 15:43, GOTOU Yuuzou wrote: > > If it can respond to get_instance and service, any kind of > > object can be mounted as a servelet. > > << cut >> > > That's very helpful, thank you very much GOTOU. > > The code shouldn't depend on the implementation of WEBrick however, do > you think we can rely on the outlined sequence > > � << accept connection and receive HTTP request >> > � << find a ServletClass associated with path of URL >> > > � # the third and more arguments of mount() will be passed to options. > � servlet = ServletClass.get_instance(server, *options) > � servlet.service(req, res) > > � << send response >> Yes, requirement of get_instance and service is the spec of WEBrick::HTTPServer. I guess it will not be changed. # at least in Ruby-1.8.. By the way, the code of servlet activation is described in HTTPServer#service. We can rewrite it to build specific purpose server or realize another idea about uri-to-service mapping. require "webrick" class NotFoundServer < WEBrick::HTTPServer def service(req, res) # returns 404 against every request. raise WEBrick::HTTPStatus::NotFound end end NotFoundServer.new(:Port=>10080).start -- gotoyuzo