What is the exact difference between Rack and Rails Metal in Ruby on Rails

送分小仙女□ 提交于 2019-12-13 00:48:25

问题


I am newbie to Rack and Rails metal, can anyone tell me which situation has to use which?. According to my understanding both Rack and Metal to filter/bypass http request and response. Need a better clarification, when to use what? Thanks in advance!!!


回答1:


As far as I know Rails Metal has been removed from Rails 3 a long time ago. Basically it used to be a thin wrapper around Rack that could act more like an endpoint rather than a filter (which is usually the case with Rack middleware). Check this post for a more detailed explanation: http://jnewland.github.io/articles/2008/12/16/rails-metal-a-micro-framework-with-the-power-of-rails-m/

Nowadays, as an alternative, what you can use is ActionController::Metal which is a very lightweight controller that can provide very fast responses without offering many of the "cool" Rails stuff.

As far as Rack is concerned it is basically:

a minimal interface between webservers supporting Ruby and Ruby frameworks.

So it basically helps standardize the communication between any webserver that supports Ruby with any possible Ruby web framework.

Here is a nice schematic representation of what Rack does taken from Passenger's docs



来源:https://stackoverflow.com/questions/21603658/what-is-the-exact-difference-between-rack-and-rails-metal-in-ruby-on-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!