【发布时间】:2014-01-09 20:06:30
【问题描述】:
我一直在 config/environments/staging.rb 中使用以下内容来保持我的 staging 环境私有:
# HTTP Basic Authentication
if ENV['AUTH_BASIC_ON'] == 'true'
config.middleware.insert_before(ActionDispatch::Static, 'Rack::Auth::Basic', 'Staging') do |username, password|
[username, password] == [ENV.fetch('AUTH_BASIC_USERNAME'), ENV.fetch('AUTH_BASIC_PASSWORD')]
end
end
config.middleware.insert_before 的第三个参数 ('Staging') 是什么?这个特定参数有什么含义?如果我想在production 中运行此代码(通过将其复制/粘贴到config/environments/production.rb),我应该将此参数更改为'Production' 吗?如果我把它改成'Fubar'呢?
我尝试在docs 和source code 中查找此内容,但无法解释。另外,我找到了它mentioned in a book,但解释充其量是薄弱的:
args 参数是一个可选的属性散列,用于传递给 Rack 过滤器的初始化方法。
【问题讨论】:
标签: ruby-on-rails http-authentication rack-middleware