|
Subject: Re: Review of CL web server APIs: Hipy Newsgroups: gmane.lisp.web Date: 2003-08-19 20:47:42 GMT (5 years, 45 weeks, 4 days, 14 hours and 59 minutes ago)
John Foderaro <jkf <at> franz.com> writes:
> >> Ok, that's Araneida in a nutshell. Next up? Someone want to
> >> tackle paserve or cl-modlisp?
I'm in the middle of building a new scheme based webserver called HIPY
(Hipy Isn't Patchy Yet). It comes out of experience of building a Java
based servlet container for the GNU project and from my wish list
from building webapps over the last 10 years.
HIPY maps a heirarchially defined, regular expression based namespace
to scheme handler procs. The namespace is defined in an XML file and
converted to an s-expression at startup.
The unusual part is that the handler procs are passed the regexp
match data when they are called. This is a lot more expressive and
powerful than the ordinary CGI path-match + path-info data passed to
handlers.
HIPY relies on scheme environments. The XML configuration file must
include an INIT element which specifies a scheme file to load or the
text of a scheme program. This scheme must create the bindings which
will be availble to map.
Thus a config file looks like this:
<?xml version="1.0"?>
<hipy-config>
<init>
(define with-connection
(make-db-con-pool "db" "user" "pass"))
(define (blog-xml . entry)
(with-connection ...))
(define (blog-list path-match method headers in out)
(if (not (eq? method 'GET))
(throw 'http-method-not-supported))
(let ((rss (blog-xml)))
(http-respond out 200 "application/xml+rss")
(send out (xslt-exec rss "some.xslt"))))
(define (blog-entry path-match method headers in out)
(let ((rss (blog-xml (match:substring path-match 1))))
(http-respond out 200 "text/html")
(send out (xst-exec rss "rss-to-html.xslt"))))
</init>
<host name="www.tapsellferrier.co.uk">
<mapping location="/blog" handler="blog-list" >
<mapping location="/\([0-9]+\)" handler="blog-entry"/>
</mapping>
</host>
</hipy-config>
Create a two level namespace where you can ask the server for URLs
like this:
/blog invokes blog-list handler
/blog/1 invokes blog-entry handler
/blog/2 invokes blog-entry handler
HIPY is threaded as per the Stevens recommendations for servers: the
accept is in the thread and thread blocking is used to select the
next acceptor.
It's all done using Guile right now, quite a bit might end up
implemented in C.
It's a bit of fun really but I though you all might be interested.
--
Nic Ferrier http://www.tapsellferrier.co.uk
|
|
|