Action Dispatch Static¶ ↑
此中间件在可用时从磁盘提供静态文件。如果找不到文件,它会将请求转交给主应用程序。
在 Rails 应用程序中,此中间件被配置为从 public/ 目录提供资源。
仅提供 GET 和 HEAD 请求。POST 和其他 HTTP 方法会转交给主应用程序。
仅提供根目录中的文件;禁止路径遍历。
方法
- C
-
- N
-
类公共方法
new(app, path, index: "index", headers: {}) Link
Source: show | on GitHub
def initialize(app, path, index: "index", headers: {})
@app = app
@file_handler = FileHandler.new(path, index: index, headers: headers)
end
实例公共方法
call(env) Link
Source: show | on GitHub
def call(env)
@file_handler.attempt(env) || @app.call(env)
end