C/Ruby 接口的最佳选择
我有一个 Ruby on Rails 应用程序,它需要与后端 C 应用程序通信,我想知道最佳方法的共识是什么。
这两个应用程序将在不同的服务器上运行,Rails 应用程序在(部分)公共网址上运行。 C 应用程序完全位于防火墙内。出于安全原因,我不希望他们共享数据库。我最初的方法是 Web 服务是正确的选择。
首先,我是否缺少任何可能比我的网络服务假设更好的替代方案?
其次,虽然我在使用 gSOAP 中的 C 中的 SOAP 方面拥有丰富的经验(重要的是,将编写 C 端的人也有丰富的经验!),但 Ruby on Rails 更喜欢 REST 模型。
但是 C 代码的 RESTful 接口到底需要什么?有没有像 gSOAP 这样的东西可以实现 C 的 RESTFUL 接口?
有没有人感觉这里阻力最小的路径是什么?
编辑:忘记提及 C 应用程序确实已经有一个使用 Aapche / CGI 的 Web 界面。
I've got a Ruby on Rails application, which needs to communicate with a backend C application, and I'm wondering what the consensus is for the best approach is to this.
The two applications will run on separate servers, with the Rails application on a (partially) public web address. The C application is entirely within a firewall. For security reasons, I don't want them sharing a database. My initial approach is that web services is the right way to go.
Firstly, am I missing any potentially better alternatives to my web services assumption?
Secondly, while I've got plenty of experience using SOAP from C with gSOAP (and importantly, so does the person who will be writing the C-side!), Ruby on Rails prefers the REST model.
But what exactly does a RESTful interface from C code entail? Is there anything like gSOAP that does RESTFUL interfaces from C?
Does anyone have a feeling which is the path of least resistance here?
EDIT: forgot to mention that the C application does already have a web interface using Aapche / CGI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 C 调用 Rails,libcurl 可能是一个不错的选择。进行 REST 调用非常简单,因为它主要是通过字符串连接加上表单编码的 url。例子很丰富:
http://curl.haxx.se/libcurl/c/example.html
如果您需要通过 REST 将 Rails 转为 C...呃。也许是 Apache 和直接的 cgi?或者只是将其包装在它自己的 Rails 应用程序中并直接从该应用程序进行调用?说真的,如果您需要通过 REST 使用 Rails to C,我希望您能得到一个好的答案。
For C calling Rails, libcurl is probably not too bad an option. Making REST calls is pretty simple, since it's mostly url via string concatenation plus form-encoding. Examples are abundant:
http://curl.haxx.se/libcurl/c/example.html
If you need Rails to C via REST ... ugh. Perhaps Apache and straight cgi? Or just wrap it in it's own rails app and do the calls directly from that app? Seriously, If you need Rails to C via REST, I hope you get a good answer.