Is there an equivalent to ASP.NET Web API in the Rails world?

Or is Rails by itself just good for developing APIs?

It seems that ASP.NET Web API project types have some history intertwined with WCF (as is detailed in this post for example), so maybe it's not applicable to Rails.

UPDATE

To clarify, Microsoft has the ASP.NET MVC framework. Recently, they came out with a framework called ASP.NET Web API. ASP.NET Web API seems to have similarities to ASP.NET MVC, but is specialized and trimmed down for RESTful web services. Is there an equivalent in the Ruby/Rails space?


So, the answer is Yes to both questions. Rails does have an equivalent and its Rails .

ASP.NET Web API looks like at it's heart is just a RESTful router with type negotiation. I could be totally off base here, but from the tutorials I saw that's what it looked like to me.

So yes, from what I can tell, Rails supports most of the things that the Web API was created for. In fact in Rails most of this stuff is forced onto you until you become informed enough to be able to change it (assuming by that point you know better than to actually do that).

But, as far as Web API functionality. That really comes from the ability to support HTTP verbs ( GET , POST , PUT , DELETE ) which Rails does.

But a source of confusion might be that in Rails the RESTful API is actually the application itself. Meaning you don't need to implement any other libraries, it's just built that way.

Here's a quick example of that I mean
When you hit /users/1 you will get the data associated with that user depending on the format you requested. So if you request JSON the controller returns JSON , HTML you get HTML , XML you get XML , etc. (As long as said format is implemented for that resource)

A good overview of what I'm talking about are in these two sections:
Rails Guides::Controller: Rendering xml and json data
Rails Guides::Routing: Resources on the Web

So you could build a website, API, or both in a Rails app and they would all start the same way.

But from my limited knowledge on the matter, I would say a ASP.NET MVC with ASP.NET Web API program is actually a lot more like a Rails Program than the regular ASP.NET MVC programs that came before them.

Or it's all just a clever ploy to get as many Capital Letters in a title as humanly possible.


Take a look at grape. It is a pure "Rest" HTTP API framework in ruby.


WSO2看起来像一个通用的Web服务框架(与Rails相反,不像MVC)我不能担保它,但它似乎更像WCF Web API的风格的服务框架(服务在一般意义上,而不仅仅是SOAP) 。

链接地址: http://www.djcxy.com/p/20512.html

上一篇: 如何保护ASP.NET Web API

下一篇: 在Rails世界中是否有与ASP.NET Web API相当的功能?