Class JythonResponse
- java.lang.Object
-
- com.xebialabs.xlplatform.endpoints.JythonResponse
-
public class JythonResponse extends java.lang.Object
Response object which is always available asresponse
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
Constructors Constructor Description JythonResponse()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getEntity()
java.util.Map<java.lang.String,java.lang.String>
getHeaders()
java.lang.Integer
getStatusCode()
void
setEntity(java.lang.Object entity)
Sets body of the response which will be serialized into JSON and returned to the client.void
setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Sets response headers.void
setStatusCode(java.lang.Integer statusCode)
Sets an HTTP status code for the response.
-
-
-
Method Detail
-
getEntity
public java.lang.Object getEntity()
-
getStatusCode
public java.lang.Integer getStatusCode()
-
getHeaders
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
-
setEntity
public void setEntity(java.lang.Object entity)
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
public void setStatusCode(java.lang.Integer statusCode)
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
public void setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Sets response headers. E.g.:response.headers = {'Location': 'http://google.com'}
-
-