在 Rails 中间件中使用 request.env
我正在尝试在 Rails 中间件中使用 Passenger 的请求变量,以便我可以将信息发送到 OmniAuth 策略:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :casmate, {
:setup => true,
:dn => request.env['SSL_CLIENT_S_DN']
}
end
但中间件中无法识别“请求”。有没有办法在中间件中执行此操作,或者有没有办法在控制器中调用中间件并传递相同的符号(:casmate、:setup、:dn)?
感谢您的帮助。
I am trying to use Passenger's request variable within my Rails middleware so I can send information to an OmniAuth strategy:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :casmate, {
:setup => true,
:dn => request.env['SSL_CLIENT_S_DN']
}
end
but "request" isn't recognized within the middleware. Is there a way to do this within the middleware, or is there a way to invoke the middleware in a controller and pass in the same symbols (:casmate, :setup, :dn)?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道如何在中间件初始化程序中使用 request.env 变量,但如果您想发送任何信息,您可以在
控制器内部的 options hash by: 中执行此操作。
I don't know how to use the request.env variable within a middleware initializer, but if you want to send any information, you can do so within the options hash by:
inside of your controller.