[plt-scheme] URL rewrite/dispatch in PLT Web server

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sat Mar 24 10:31:52 EDT 2007

Hey Sridhar,

> I have been poking around the PLT web server and continuation based
> web programming for a while (after reading the recent 2007 paper on
> plt-web-server by Shriram Krishnamurthi). I believe not all of web can
> be programmed using continuations. There is a need for standard URL
> dispatch mechanism too (which goes through unique code entry points).
> Assuming we use servlets, a weblog permalink will look like this,
>  http://example.com/servlets/weblog.ss/2006/02/foo-bar.html
> "/2006/02/foo-bar.html" becomes the PATH_INFO component of the request url.
> There is clearly no way to think in terms of continuations (as there
> is no end-user specific interaction) here. Correct me if I am wrong.

This is no different than visiting /servlets/servlet.ss, it is the
start of some interaction that may or may not have multiple steps (and
therefore continuations that model them.)

> >From what I know, there is no dispatch mechanism in PLT other than me
> inspecting the PATH_INFO variable and dispatching to code entry points
> accordingly. This is pretty much similar to the standard CGI model.

You can recreate the CGI model exactly in PLT, if you so desire.

> Can I do better than that?

Anything that `works' better in other systems is possible. For
example, you could construct a functon to `eval' from the URL, which
is basically what Ruby on Rails does where the function constructed
comes from a macro or is defined by hand.

> Also, does PLT web server support a way to rewrite urls (back and
> forth)? For example, the above url can instead be
> http://example.com/2006/02/foo-bar.html and k-urls like
> http://example.com/servlets;4*2*25232234/post can become
> http://example.com/post;k=4*2*25232234

Yes, you can do that. Your servlet code sees URLs as strings, so it
can rewrite them anyway it wishes before sending them out. And, there
is a `dispatcher' API where you can route/rewrite the request object
before the standard servlet dispatcher gets it.

> Any help would be much appreciated. I am craving to write (web2.0
> style) web apps in PLT scheme.

We are craving web2.0 style web apps in PLT Scheme and are happy to
oblige. Also, check out flapjax-lang.org for some new work from
Shriram's team.


Jay McCarthy <jay.mccarthy at gmail.com>

Posted on the users mailing list.