Dear RESTafarians: Introducing RESTfulCF

Dear RESTafarians,

I thought I’d take the opportunity to introduce this new CF/REST project: RESTfulCF; it’s a framework for publishing a REST interface to a ColdFusion application. The code is freely available. Bug reports should be made on the RESTfulCF issue tracker.

Everywhere you look now, people are opening up their data via APIs: Google, Flickr, Twitter, Facebook - the list goes on and on. You can find an API for anything from discovering who your local MP is, finding song lyrics, or discovering new species of fungi and micro-organisms. RESTfulCF provides a framework for publishing a REST API of your own.

The framework has been extracted from some of my recent work on the White Label Dating platform. We needed to be able to provide a simple REST interface on top of our existing ColdFusion app for use on various key internal projects, including a new Ruby on Rails system, and a Javascript-based reporting dashboard. The framework is currently in production use on the White Label Dating platform.

The basic principles of RESTfulCF are:

  • Resources are implemented as components, with properties of the resource defined using <cfproperty> tags. onMissingMethod() is used to provide implicit setter/getter functions for those properties;
  • There are default representations which apply to every resources (unless overridden within the resource component itself), which means writing a lot less code;
  • Controllers are the “glue” that makes the system work: functions are defined to handle each type of request (read all resources, read one resource, create a new resource etc) that may be made of a resource;
  • Convention-over-configuration for defining routes: a single function call of addResource("world") will automatically map common URI patterns to a Worlds controller, for example `GET /worlds/:id` will be mapped to the `read` function.

RESTfulCF also provides a number of other helpful features:

  • automatic resource collection handling;
  • standardised error reporting and attribute typing (including precision) in XML representations, allowing simple consumption of the API by Ruby in Rails using ActiveResource (or HyperActiveResource);
  • very simple to work with: an endpoint file, a dispatcher, plus one or more controllers and resource description files, and you’re up and running.

In general, RESTfulCF has been designed to provide a lightweight interface sitting on top of an existing business logic layer, rather than to provide the whole application itself.

Please use and abuse the framework: check out the sample application, write your own resources and controllers and let me know your thoughts. Or, if you feel adventurous, fork it on GitHub and check something off the to-do list.

Let your data loose!

Comments
Shannon Hicks's Gravatar Now if you just combine that with oAuth, you'll have done 50% of my coding for an upcoming project API expansion :)
# Posted By Shannon Hicks | 7/17/09 12:12 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress