Monday, December 08, 2008


OpenRasta is a REST based framework for building web applications. The source has just been released here. RASTA stands for REST Architecture Solution Targeting (phew). The man behind OpenRasta is Sebastien Lambla, who's well known for organising the popular beers in London and speaking at community events. Here's Seb's description of it:

"Rasta takes a radically different approach. Every Url is mapped to a resource. In other words, is mapped to a resource of type CustomerEntity. Each resource type can have many resource handlers that are responsible for acting upon a resource in a certain way. This could mean retrieving a resource, updating it, etc.

When you access a Url to get to a resource (called dereferencing), the first step Rasta is going to take is to try and locate which handler can be used to access the resource, based on the request you made. For example,{name}  is a Url that would associate a meaning of name with a value to the handler. From that name, the handler would return an instance of the resource (an instance of CustomerEntity). In other words, a handler is responsible for dereferencing a Uri based on a request to get to a resource, and to act upon it if required.

And that's it. The handler is not involved at any point in how the request is processed or how the response is sent to the client. This is the responsibility of the codecs.

A codec is a component that, to simplify, convert a Content-Type sent on the wire to an object and back. In essence, if your handler returns an instance of CustomerEntity, the codec will be able to convert it into an xml stream representation, or whatever wire format the codec supports. Out of the box, the current Rasta svn repository has support for webforms (for html rendering), json and xml, and I have some working code supporting AtomPub, atom, rss and even support for some WebDav, although all this is mostly prototype quality.

In this model, the resource is the resource, and its representations are handled by codecs that are loosely coupled from the resource itself. You could see it as an application of the semantic web, but based on types and objects. In other words, it works and is good enough."

After hearing Seb speak about it and chatting with him over a couple of beers, it does appear to be a very compelling way of thinking about web applications. A single alternative to the plethora of frameworks (MVC Framework, WCF, ADO.NET Data Services) coming out of Microsoft. He has promised an OpenRasta version of Suteki Shop which I'm really looking forward to seeing. No pressure there Seb :)

No comments: