当我注释掉下面的线程相关代码时,对slack API的提交按预期工作。但是,当我尝试在线程命令中处理提交时,提交永远不会通过。
我做错了吗?在Railo 4中运行
// push to slack!
public function push(options = {}) {
var http = new http();
var data = {
"text": "Default message",
"channel": "activity"
};
structAppend(data, options);
// thread
// action="run" {
sleep(5000);
http.setMethod("post");
http.setUrl(variables.slackWebhookUrl);
http.addParam(
type = "formField",
name = "payload",
value = serializeJson(data)
);
http.send();
// }
}
答案 0 :(得分:2)
为了简洁起见,我会说在将来使用线程时我将遵循这些规则:
这是有效的代码:
// push to slack!
public function push(options = {}) {
var data = {
"text": "Default message",
"channel": "activity"
};
structAppend(data, options);
thread
action="run"
data="#data#"
slackUrl="#variables.slackWebhookUrl#" {
var http = new http();
http.setMethod("post");
http.setUrl(attributes.slackUrl);
http.addParam(
type = "formField",
name = "payload",
value = serializeJson(attributes.data)
);
http.send();
}
}