Hello RESTafarians,
I thought I'd take the opportunity to introduce a new CF/REST project:
RESTfulCF; it's a framework for publishing a REST interface to a
ColdFusion
application.
The project is linked through from RIAForge, and the code is hosted on
GitHub:
http://restfulcf.riaforge.org/
http://github.com/timblair/restfulcf/tree/master
The framework has been extracted from some of my recent work on the
White
Label Dating (
http://www.whitelabeldating.com/) 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 propertise;
* 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.
"Why not use PowerNAP?", you may ask. Good question! I think the
work
Brian's put in to PowerNAP has resulted in an excellent framework, but
after reviewing our needs there were a few things that either didn't
sit
quite right with me, or that we just didn't need, such as Coldspring-
based
resources, per-resource authentication and the explicit separation of
resources from representations
In addition, a number of features that we required (for example:
default
representations, collection handling, Rails-isms for error reporting
and
attribute typing in XML representations) would have been difficult to
implement in PowerNAP.
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.
Your thoughts and comments would be greatly appreciated.
Thanks,
Tim.
--
Tim Blair
http://tim.bla.ir/