我想知道API中所有功能都受到限制,如果我们使用Base代替API,速度会有什么差异吗?
我搜索了很多地方来找到这两个模块之间的区别,我所知道的 API 是 Base 的轻量级版本。
了解两者之间差异的最佳来源当然是它们在源代码中包含的模块列表。
ActionController::Base
包括这些模块(注释已删除并按字母顺序排序):
MODULES = [
AbstractController::AssetPaths,
AbstractController::Callbacks,
AbstractController::Rendering,
AbstractController::Translation,
ActionView::Layouts,
Caching,
ConditionalGet,
ContentSecurityPolicy,
Cookies,
DataStreaming,
DefaultHeaders,
EtagWithFlash,
EtagWithTemplateDigest,
Flash,
FormBuilder,
Helpers,
HttpAuthentication::Basic::ControllerMethods,
HttpAuthentication::Digest::ControllerMethods,
HttpAuthentication::Token::ControllerMethods,
ImplicitRender,
Instrumentation,
Logging,
MimeResponds,
ParameterEncoding,
ParamsWrapper,
PermissionsPolicy,
Redirecting,
Renderers::All,
Rendering,
RequestForgeryProtection,
Rescue,
Streaming,
StrongParameters,
UrlFor,
]
ActionController::API
仅包括这些(再次,评论被删除并按字母顺序排序):
MODULES = [
AbstractController::Callbacks,
AbstractController::Rendering,
ApiRendering,
BasicImplicitRender,
ConditionalGet,
DataStreaming,
DefaultHeaders,
Instrumentation,
Logging,
ParamsWrapper,
Redirecting,
Renderers::All,
Rescue,
StrongParameters,
UrlFor,
]