--orO6xySwJI16pVnm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Kirk Haines (khaines / enigo.com) wrote: > I think I know the answer to this already, but.... > > Are there any not-so-easy-to-find documents anywhere on using Webrick? API > docs or howto docs or anything like that? > > I'm going to make Iowa capable of using webrick so that an Iowa application > can be a completely standalone application server. From what I can tell, > this graft looks like it should be an extremely simple one, but I haven't > been able to find a lot of documentation so I'm mostly going to be working > from looking at the webrick code and at other pieces of software that use > it, unless someone can point me to something that I have missed. > > If there is nothing, then I will try to document what I learn while I go > about this project as a way to start making some practical HOWTO type > documentation available for webrick. I haven't found any, but the Servlets provided with WEBrick are a good start. Here's a template: class MyServlet < WEBrick::HTTPServlet::AbstractServlet ## # your_arguments stands in for any extra arguments # # Of course, you may omit #initialize if you don't use extra args def initialize(server, your_arguments) super # setup from your_arguments end ## # HTTP method handlers are prefixed with do_ def do_GET(request, response) status, headers, body = do_stuff_with(request) response.status = status response.headers = headers response.body = body end alias do_POST do_GET end To mount the servlet: server = WEBrick::HTTPServer.new server.mount "/some/path", MyServlet, any_extra_args Any arguments after the servlet class get passed to the servlet's #new method. Here's the one I use for Borges: http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/borges/lib/Borges/WEBrick.rb?rev=1.13&cvsroot=borges&content-type=text/vnd.viewcvs-markup > > > Thanks, > > Kirk Haines > -- Eric Hodel - drbrain / segment7.net - http://segment7.net All messages signed with fingerprint: FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --orO6xySwJI16pVnm Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQFAslw5MypVHHlsnwQRArH1AJ9zcBk0y6ZX1bgI1scygEcMTaT3LgCg8/X+ D/8uHzntWtJrILXN8L1TQwU 0J -----END PGP SIGNATURE----- --orO6xySwJI16pVnm--