Rails,您如何以绝对最低的级别访问原始请求数据? [英] Rails, how do you access the raw request data at the absolute lowest level?

查看:77
本文介绍了Rails,您如何以绝对最低的级别访问原始请求数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails request对象在请求生命周期中最早何时可用?本质上,请求什么时候最先作为请求对象可用,在哪个对象中可用? ActionDispatch?

When is the Rails request object available at the earliest time during the request lifecycle? Essentially, when is the request first available as a request object, and in which object? ActionDispatch?

您可以从Tester::Application访问请求参数吗?如果是这样,怎么办?如果没有,那么如何使用环境?该信息何时设置?

Can you access request parameters from Tester::Application? If so, how? If not, what about using the environment? When is that information set?

推荐答案

Rack网络服务器创建request对象,然后ActionDispatch继承该对象.因此,从本质上讲,您将能够访问应用程序中间件中的Rack::RequestActionDispatch::Request对象.

The Rack webserver creates the request object and then ActionDispatch inherits from it. So essentially, you'd be able to access the Rack::Request or ActionDispatch::Request objects within the middleware of the app.

机架::请求

https://github.com/rack/rack/blob/master/lib/rack/request.rb

ActionDispatch ::请求

https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/request.rb

这篇关于Rails,您如何以绝对最低的级别访问原始请求数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆