renderData()
that can take any type of data and marshall (convert) it for you to other formats like xml, json, wddx, pdf, text, html
or your own type.renderData()
here http://apidocs.ortussolutions.com/coldbox/current/index.html?coldbox/system/web/context/RequestContext.html#renderData()handlers/contacts.cfc
and add to our current code:Accepts
header. If no extension is sent, then ColdBox attempts to determine the format by inspecting the Accepts
header. If we still can't figure out what format to choose, the default of html
is selected for you.format
with the correct format type: ?format=json
./contacts/index.json
. You will do so by leveraging the application's router found at config/Router.cfc
. Find the configure()
method and let's add a new route:route()
method allows you to register new URL patterns in your application and immediately route them to a target event. You can even give it a human readable name that can be later referenced in the buildLink()
method./api/contacts
that if detected will execute the contacts.index
event. Now reinit the application, why, well we changed the application router and we need the changes to take effect.http://localhost:{port}/?fwreinit
.