Creating a Handler
Background
Handlers are the first code that is run when a route is hit. It's where much of the prelim work of a request is handled such as authentication, data validation, data cleanup and so on.
Creating a Handler
We are focussing on a Rest API paradigm so all of the handlers we are going to create will extend the RestHandler component which is part of the ColdBox system. Create the file handlers/Users.cfc and paste this as the contents.
component extends="Coldbox.system.RestHandler" {
function index(event, rc, prc){
prc.response.setData("Hello");
}
}event - Represents the request and all of the data that Coldbox uses to process is.
rc - the collection of data received as part of the request including the URL and FORM scopes. This includes any data considered non-trusted
prc - a collection of data which is generated by our app and can be considered trust worthy
prc.response - The response object which includes status codes, return data, pagination data and more.
Last updated