ActionPack 和 Rack 有什么区别? (Rails)
What is the difference between ActionPack and Rack? (Rails)
我正在尝试更深入地了解 Ruby on Rails 框架,并且我一直在谷歌搜索大量我听到但从未理解的术语。
其中两个术语是“ActionPack”和“Rack”
根据每个文件的文档:
动作包:
Action Pack is a framework for handling and responding to web requests. It provides mechanisms for routing (mapping request URLs to actions), defining controllers that implement actions, and generating responses by rendering views, which are templates of various formats. In short, Action Pack provides the view and controller layers in the MVC paradigm.
机架:
Rack provides a minimal interface between webservers that support Ruby and Ruby frameworks.
根据我一直在进行的谷歌搜索,我已经将以下模型放在一起,但我仍然有点不确定:
如果我理解正确,Rack 更像是一个 specification/standard 作为 application/program 应该接受的 input/produce 作为输出(执行此操作的程序被认为是“机架兼容” ). ActionPack 是 rails 用来执行此操作的程序。所以请求会是:Client HTTP request --> Server --> ActionPack --> The Rest of Rails etc.
这是正确的吗?还是我理解错了?
许多其他框架可以是Rack-based应用程序,例如Sinatra or Grape。
To use Rack, provide an "app": an object that responds to the call
method, taking the environment hash as a parameter, and returning an Array with three elements:
The HTTP response code
A Hash of headers
The response body, which must respond to each
这意味着:借助 rack,您可以直接与 Web 请求进行交互,从而允许社区构建基于该简单交互规则的不同工具或框架。有问题的 app
对象是框架。
ActionPack
是 Rails' 与 Rack 交互的部分,它由 ActionController
和 ActionView
的组合组成,这使得我们奇妙的 MVC 架构就像它一样是。检查 this answer for a detailed view on ActionPack
我正在尝试更深入地了解 Ruby on Rails 框架,并且我一直在谷歌搜索大量我听到但从未理解的术语。
其中两个术语是“ActionPack”和“Rack”
根据每个文件的文档:
动作包:
Action Pack is a framework for handling and responding to web requests. It provides mechanisms for routing (mapping request URLs to actions), defining controllers that implement actions, and generating responses by rendering views, which are templates of various formats. In short, Action Pack provides the view and controller layers in the MVC paradigm.
机架:
Rack provides a minimal interface between webservers that support Ruby and Ruby frameworks.
根据我一直在进行的谷歌搜索,我已经将以下模型放在一起,但我仍然有点不确定:
如果我理解正确,Rack 更像是一个 specification/standard 作为 application/program 应该接受的 input/produce 作为输出(执行此操作的程序被认为是“机架兼容” ). ActionPack 是 rails 用来执行此操作的程序。所以请求会是:Client HTTP request --> Server --> ActionPack --> The Rest of Rails etc.
这是正确的吗?还是我理解错了?
许多其他框架可以是Rack-based应用程序,例如Sinatra or Grape。
To use Rack, provide an "app": an object that responds to the
call
method, taking the environment hash as a parameter, and returning an Array with three elements:The HTTP response code
A Hash of headers
The response body, which must respond to each
这意味着:借助 rack,您可以直接与 Web 请求进行交互,从而允许社区构建基于该简单交互规则的不同工具或框架。有问题的 app
对象是框架。
ActionPack
是 Rails' 与 Rack 交互的部分,它由 ActionController
和 ActionView
的组合组成,这使得我们奇妙的 MVC 架构就像它一样是。检查 this answer for a detailed view on ActionPack