Thursday, May 04, 2006

Camping and microframeworks

I'm loving Camping, a web framework that's 4k in size written in Ruby. I just learned it yesterday. All I need is a simple dynamic web site and I can wrote the whole thing in--let me look--146 lines with comments.

It's great because it's set up to be URL/controller-friendly. What do I mean by that? Most web frameworks force you into some limited URL scheme. Especially Java servlet containers. But I love the REST style and want my URLs to name resources, not actions. (Use HTTP people!)

Boiled down to the actual program, this means that URLs need to map to model objects, the M in MVC. In Camping, you do this:
class Provider < R(/(\d+)/)    
def get provider_id
provider = Provider.find provider_id
# do something with provider object
This says the URL /3 maps to a Provider object with id 3.

In Java I created an interface called ResourceMapping that mapped between URLs and a Map of objects. I haven't found a Java web framework that provides this kind of emphasis on resources.


Post a Comment

Links to this post:

Create a Link

<< Home