Class JythonResponse
java.lang.Object
com.xebialabs.xlplatform.endpoints.JythonResponse
Response object which is always available as
response
inside Jython scripts which implement REST endpoints in XL extensions.
The content of HTTP response returned to the client will be the following:
{
entity: "object, or array",
stdout: "Text which has been sent to standard output during the execution",
stderr: "Text which has been sent to standard error during the execution",
exception: "Textual representation of exception that has been thrown during script execution"
}
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Sets body of the response which will be serialized into JSON and returned to the client.void
setHeaders
(Map<String, String> headers) Sets response headers.void
setStatusCode
(Integer statusCode) Sets an HTTP status code for the response.
-
Constructor Details
-
JythonResponse
public JythonResponse()
-
-
Method Details
-
getEntity
-
getStatusCode
-
getHeaders
-
setEntity
Sets body of the response which will be serialized into JSON and returned to the client.response.entity=[{"foo": 42, "bar": "some value"}, 34]
Supported types are:- Standard JSON data types:
Number
,String
,Boolean
,Array*
,Dictionary*
- XL configuration items: ConfigurationItem
Array
andDictionary
can recursively contain aforementioned types as values of their elements. - Standard JSON data types:
-
setStatusCode
Sets an HTTP status code for the response. Normally this HTTP status code will be returned to the client. E.g.:response.statusCode = 307
. If this value is not set and script has been executed successfully, client will receive200
. If script throws exception which is not caught, this value will be ignored and500
will be returned. -
setHeaders
Sets response headers. E.g.:response.headers = {'Location': 'http://google.com'}
-