Class: RestOperation(eventChannel)¶
Name | Required | Type | Default Value | Description |
---|---|---|---|---|
eventChannel | Y | EventEmitter | common node event channel for all operations |
RestOperation Methods¶
(instance) -> setUri(uri)¶
Sets the uri for this RestOperation object
Name | Required | Type | Default Value | Description |
---|---|---|---|---|
uri | Y | url | uri to use requests sent using this RestOperation object will be sent to the provided uri |
Type | Description |
---|---|
restOperation | this value for chaining |
(instance) -> getReferer()¶
gets the’referer’ header field for this RestOperation object
Type | Description |
---|---|
string | referer in incoming message |
Examples:
(instance) -> setReferer(referer)¶
sets the referer for this RestOperation object
Name | Required | Type | Default Value | Description |
---|---|---|---|---|
referer | Y | string | to use in outgoing messages requests sent using this RestOperation object will be sent to with the referer set to the provided value |
Type | Description |
---|---|
restOperation | this value for chaining |
(instance) -> getUri()¶
gets the uri for this RestOperation object
Type | Description |
---|---|
uri | uri used in incoming message |
Examples:
(instance) -> getBody()¶
gets the request body for this RestOperation object
Type | Description |
---|---|
object | body the body of the message |
Examples:
MyWorker.prototype.onPut = function(restOperation) {
// this code will extract the content of "SomeData" field in an incoming REST PUT request, e.g. if the incoming JSON is
//{
// SomeData: "Hello",
// MoreData: "Bye"
//}
// the code below will output
// SomeData is: Hello
var newData = restOperation.getBody().SomeData;
this.logger.info("SomeData is:"+newData);
}
(instance) -> setBody(requestbody)¶
sets the request body for this RestOperation object
Name | Required | Type | Default Value | Description |
---|---|---|---|---|
requestbody | Y | object | object to be serialized in to the JSON of outgoing message |
Type | Description |
---|---|
restOperation | this value for chaining |
Examples:
// sets the body of the RestOperation to the object O
// Object O has the fields a and b
// so the outgoing message (received on GET) will look like
// {
// a: "hello",
// b: 99
// }
MyWorker.prototype.onGet = function(restOperation) {
var o = {a: "hello", b: 99};
restOperation.setBody(o); // set the body of the outgoing operation to the object o
this.completeRestOperation(restOperation);
return;
};
(instance) -> setMethod(method)¶
sets the request method (GET, PUT, POST, PATCH, DELETE) for this RestOperation object should use one of the predefined RestOperation.Method.* constants
Name | Required | Type | Default Value | Description |
---|---|---|---|---|
method | Y | string | method to use in the request |
Type | Description |
---|---|
restOperation | this value for chaining |
Examples:
(instance) -> getMethod()¶
gets the request method (GET, PUT, POST, PATCH, DELETE) for this RestOperation object
Type | Description |
---|---|
string | method for this restOperation |
Examples:
(instance) -> setStatusCode(statusCode)¶
sets the status code provided with this restOperation. Status codes are as defined in the HTTP stanard and can also be found as constants on WellKnownPorts
Name | Required | Type | Default Value | Description |
---|---|---|---|---|
statusCode | Y | number | status code to be returned as the result of the restOperation call |
Type | Description |
---|---|
restOperation | this value for chaining |
Examples:
(instance) -> getStatusCode()¶
gets the status code provided with this restOperation
Type | Description |
---|---|
number | status code |
Examples:
(instance) -> setContentType()¶
sets the content type for the response provided with this restOperation
Type | Description |
---|---|
string | contentType |
Examples:
(instance) -> getContentType()¶
gets the content type of the request associated with this restOperation
Type | Description |
---|---|
string | contentType |
Examples:
(instance) -> getBasicAuthorization()¶
gets the basic auth string for the response provided with this restOperation. This is an advanced usecase - follow HTTP specification for formatting of this field
Type | Description |
---|---|
String | the string used in the basic auth header |
Examples: