如何为 Ruby 应用程序创建 REST API? [英] How to create a REST API for a Ruby application?
问题描述
我想知道如何为 Ruby 应用程序提供 REST API.我可以根据 Ruby 的 TCPServer API 编写一些代码,但这似乎有点低级.你认为这会是一个很好的解决方案吗?或者您有什么更好的方法推荐?
I would like to know how to provide a Ruby application with a REST API. I could code something based on Ruby's TCPServer API, but that seems a bit low-level. Do you think it would be a good solution? Or do you recommend a better approach?
推荐答案
您可以使用 Sinatra 来编写tiny、专注的 Web 应用程序和轻量级 REST 服务非常快速.
You can use Sinatra to write tiny, focused web applications and lightweight REST services very quickly.
在 documentation 部分,他们重点介绍了一些关于该问题的视频:
In the documentation section they highlight a couple of videos on that matter:
Adam Wiggins 和 Blake Mizerany 在 RestClient="http://rubyconf2008.confreaks.com/lightweight-web-services.html" rel="noreferrer">RubyConf 2008.演讲详细介绍了 Sinatra 的基本理念,并反思了使用 Sinatra 构建现实世界的应用程序.
Adam Wiggins and Blake Mizerany present Sinatra and RestClient at RubyConf 2008. The talk details Sinatra’s underlying philosophy and reflects on using Sinatra to build real world applications.
Adam Keys 和 The Pragmatic Programmers 开始了一系列 截屏视频.前两集介绍了创建一个小型 Web 应用程序和创建一个 REST 服务.5 美元一次.
Adam Keys and The Pragmatic Programmers have started a series of screencasts on Sinatra. The first two episodes cover creating a tiny web app and creating a REST service. $5 a pop.
您也可以使用 rails 为好,但这有点矫枉过正...
You can also use rails as well, but that's a little overkill...
这篇关于如何为 Ruby 应用程序创建 REST API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!