From: Brad Phelan Date: 2007-08-02T17:15:04+09:00 Subject: Re: Easy REST server w/o views or controllers? > I've looked around at most of the frameworks I can find, including > Nitro, Merb, Camping, and Rails, and all of them seem to assume that I > care deeply about databases and HTML, while really all I want to do is > make it easy to provide a REST-like interface for my software to use to > talk to itself. I use camping all the time for little projects where I just want a view of something. Never used a database with it at all. With the views I guess you can render any kind of response you like. I've done simple kinds of content type negotiation for the same URL by just changing the suffix of the URL Camping.goes :app class Foo < R '/foo\.(\w+)' def get( ctype ) % Do stuff case ctype when 'html' render :foo_html when 'txt' render :foo_txt when 'xml' render :foo_xml when 'yaml' render :foo_yaml default render :fourohfour end end end then http://xtargets.com/app/foo.txt http://xtargets.com/app/foo.xml http://xtargets.com/app/foo.yaml http://xtargets.com/app/foo.html all get me the same data in with a different representation. It may be better ( though I didn't do it ) to overwrite render with your own implementation which checks content type alias :render, :old_render def render(api) if @ctype old_render "#{api}_#{@ctype}" else old_render api end end then just do class Foo < R '/foo\.(\w+)' def get( ctype ) % Do stuff @ctype = ctype render :foo end end -- Brad Phelan http://xtargets.com