requestbodyto be handled the same as FORM and URL variables you can enable
coldbox.jsonPayloadToRC = truein your ColdBox config, which is the default in ColdBox 6.
renderData()that can take any type of data and marshall it for you to other formats like
xml, json, wddx, pdf, text, htmlor your own type.
handlers/contacts.cfcand add to our current code:
Acceptsheader. If no extension is sent, then ColdBox attempts to determine the format by inspecting the
Acceptsheader. If we still can't figure out what format to choose, the default of
htmlis selected for you.
/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
/api/contactsthat if detected will execute the
contacts.indexevent. Now reinit the application, why, well we changed the application router and we need the changes to take effect.