Simple ColdBox Restful APP

Does anyone have a link for a Simple ColdBox Hello World restful app?

Hey there,

I’m not sure what you’re asking. Are you looking for a URL to take a look at (which would be Headless - i.e no UI) Or are you looking for code / how to get started building a RESTFul app.

I great place to start is by looking at the RELAX module on forgebox. It allows you to configure resources (RESTful API’s) to test against, produce documentation, and stub out the routes for the API endpoints.

Most of the magic of a RESTFul API comes from properly defining the HTTP Security for the route and handler methods


// ********** Contact endpoints *********** //

addRoute(pattern="/contacts/:contactid", handler=“Contact”,action={GET=“getContact”, PUT=“updateContact”, DELETE=“removeContact”});

addRoute(pattern="/contacts/", handler=“Contact”,action={POST=“createContact”});

i.e contact handler

this.allowedMethods = {getContact=‘GET’,createContact=‘POST’,updateContact=‘PUT’,removeContact=‘DELETE’’};

…and then using serializeJSON or event.renderData() to return whatever results back to the requesting client.

you can get funky with interceptors for security/authentication as well as do some interesting stuff with AOP for caching, etc.

Make sense?