【发布时间】:2015-05-30 08:16:42
【问题描述】:
我一直在尝试使用 POST 从 Ruby 脚本向使用 MeteorJS 构建的 web 应用程序获取消息,但我遇到了一些问题。关于 Iron Router 的 POST 和 GET 方法管理的在线文档并不多。
我的 Ruby 脚本:
meteorUri = URI('http://localhost:3000/newReport');
res = Net::HTTP.post_form(meteorUri, 'message' => 'HelloFromRuby', 'max' => '50')
puts "From Meteor:\t#{res}"
我对 Ruby 没有太多经验。上面的代码我主要是在网上弄的。
Iron Router 的路由:
Router.route('/newReport/:message', {where: 'server'})
.post( function(message){
Meteor.call('reportInsert', {message: message}, function(error, recordId){
if (error){
alert(error.reason);
} else {
console.log("Inserted " + recordId);
}
});
});
我正在尝试让 Ruby 向 http://localhost:3000/newReport 发送一条消息,该消息应该是一个字符串。
reportInsert 函数有效,我测试过了。问题似乎在于发出 POST 或接收它。
谢谢!
【问题讨论】:
-
还有什么问题?你有什么问题?
-
消息没有通过。在 Meteor 端查看 MongoDB,发现没有收到消息。
标签: ruby http post meteor iron-router