lucee.Component coldbox.system.web.context.Response
Copyright 2005-2007 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com HTTP Response model used mostly for RESTFul services, but it can be used as a nice way to represent responses in ColdBox
Property Summary | ||||
---|---|---|---|---|
type | property | default | serializable | required |
boolean
|
binary
A binary indicator.
|
false
|
true
|
false
|
string
|
contentType
The content type of the response.
|
true
|
false
|
|
any
|
data
The data struct that will be used to marshall out the response.
|
true
|
false
|
|
boolean
|
error
A boolean error indicator.
|
false
|
true
|
false
|
string
|
format
The output format of the response, defaults to json.
|
json
|
true
|
false
|
array
|
headers
The headers to send with the response.
|
true
|
false
|
|
string
|
jsonCallback
The json callback if any.
|
true
|
false
|
|
string
|
jsonQueryFormat
JSON Only: This parameter can be a Boolean value that specifies how to serialize ColdFusion queries or a string with possible values row, column, or struct.
|
true
|
true
|
false
|
string
|
location
The location header if any.
|
true
|
false
|
|
array
|
messages
An array of messages to output if any.
|
true
|
false
|
|
struct
|
pagination
The pagination struct if any.
|
true
|
false
|
|
numeric
|
responsetime
The response time.
|
0
|
true
|
false
|
numeric
|
statusCode
The status code of the response.
|
200
|
true
|
false
|
string
|
statusText
The status text of the response.
|
OK
|
true
|
false
|
Constructor Summary | |
---|---|
init()
Constructor. |
Method Summary | |
---|---|
Response
|
addHeader(string name, string value)
Add a header into the response. |
Response
|
addMessage(any message)
Add some messages to the response. |
string
|
getBinary()
|
string
|
getContentType()
|
string
|
getData()
|
struct
|
getDataPacket([boolean reset='false'])
Returns a standard response formatted data packet using the information in the response. |
string
|
getError()
|
string
|
getFormat()
|
string
|
getHeaders()
|
string
|
getJsonCallback()
|
string
|
getJsonQueryFormat()
|
string
|
getLocation()
|
struct
|
getMemento()
Utility function to get the state of this object. |
string
|
getMessages()
|
string
|
getMessagesString()
Get all messages as a string. |
string
|
getPagination()
|
string
|
getResponsetime()
|
string
|
getStatusCode()
|
string
|
getStatusText()
|
any
|
setBinary(boolean binary)
|
any
|
setContentType(string contentType)
|
any
|
setData(any data)
|
Response
|
setDataWithPagination([any data], [any resultsKey='results'], [any paginationKey='pagination'])
Sets the data and pagination from a struct with a `results` and `pagination` key. |
any
|
setError(boolean error)
|
Response
|
setErrorMessage(any errorMessage, [any statusCode], [any statusText=''])
Sets the error message with a code for the API response. |
any
|
setFormat(string format)
|
any
|
setHeaders(array headers)
|
any
|
setJsonCallback(string jsonCallback)
|
any
|
setJsonQueryFormat(string jsonQueryFormat)
|
any
|
setLocation(string location)
|
any
|
setMessages(array messages)
|
Response
|
setPagination([numeric offset='0'], [numeric maxRows='0'], [numeric page='1'], [numeric totalRecords='0'], [numeric totalPages='1'])
Set the pagination data. |
any
|
setResponsetime(numeric responsetime)
|
Response
|
setStatus(any code, [any text])
Sets the status code with a statusText for the API response. |
any
|
setStatusCode(numeric statusCode)
|
any
|
setStatusText(string statusText)
|
Methods inherited from class lucee.Component |
---|
None |
Constructor Detail |
---|
Constructor
Property Detail |
---|
A binary indicator
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe content type of the response
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe data struct that will be used to marshall out the response
access
- publicrequired
- falsereturntype
- anyserializable
- trueA boolean error indicator
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe output format of the response, defaults to json
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe headers to send with the response
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe json callback if any
access
- publicrequired
- falsereturntype
- anyserializable
- trueJSON Only: This parameter can be a Boolean value that specifies how to serialize ColdFusion queries or a string with possible values row, column, or struct
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe location header if any
access
- publicrequired
- falsereturntype
- anyserializable
- trueAn array of messages to output if any
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe pagination struct if any
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe response time
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe status code of the response
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe status text of the response
access
- publicrequired
- falsereturntype
- anyserializable
- trueMethod Detail |
---|
Add a header into the response
name
- The header name ( e.g. "Content-Type" )value
- The header value ( e.g. "application/json" )Add some messages to the response
message
- Array or string of message to incorporateReturns a standard response formatted data packet using the information in the response
reset
- Reset the 'data' element of the original data packetUtility function to get the state of this object
Get all messages as a string
binary
contentType
data
Sets the data and pagination from a struct with a `results` and `pagination` key.
data
- The struct containing both 'results' and 'pagination' keysresultsKey
- The name of the key with the results.paginationKey
- The name of the key with the pagination.error
Sets the error message with a code for the API response
errorMessage
- The error message to setstatusCode
- The status code to set, if anystatusText
- The status text to set, if anyformat
headers
jsonCallback
jsonQueryFormat
location
messages
Set the pagination data
offset
- The offsetmaxRows
- The max rows returnedpage
- The page numbertotalRecords
- The total records foundtotalPages
- The total pages foundresponsetime
Sets the status code with a statusText for the API response
code
- The status code to be settext
- The status text to be setstatusCode
statusText