Tuesday, September 16, 2008

Dispatch PLT-Scheme Module - Whetting My Scheme Web Dev Appetite

Today, while browsing around for DrSync, I stumbled on Dispatch: A tool for configuring controller procedures in web applications.. OK, maybe that title doesn't do it for you, but it certainly got me interested enough to check out the docs.

Dispatch allows you to configure a web apps URLs in a nice and neat little package. For example, you can say:

 (define-site blog
    ([(url "") list-posts]
     [(url "/posts/" (string-arg)) review-post]
     [(url "/archive/" (integer-arg) "/" (integer-arg))

to wire http://www.example.com/ into (list-posts request), http://www.example.com/posts/hello-world into (review-post request name), etc. Dispatch also allows you to get the URL to a particular controller, such as:.

(li (a ([href ,(controller-url review-post title)]) 
       "View " ,(format "~s" title))

This means no hard coding of controller URLs, which is handy. Finally, Dispatch supports arbitrary code as a URL:

`(li (a ([href ,(lambda (request)
                 (review-post request title))])
        "View " ,(format "~s" title)))

I think that last chunk of functionality (provided by the continuation based server, not really Dispatch) has incredibly huge potential.

So, I'm now eager to give this all a try. I think my biggest hurdle to get over now is production deployment. Two questions come to mind: (1) is the PLT-web server production ready? And (2) is there an affordable server deployment option I can make use of? If you have answers to these questions, I'd love it if you'd share them. Otherwise, I'm going to have to continue to watch from the sidelines, and that's no fun.

On a related note, I've seen some positive press for LeftParen, a web framework that builds on top of Dispatch (I believe). If you're looking around for Scheme based web stuff, check this package out too.

No comments:

Post a Comment