Rails, how do you access the raw request data at the absolute lowest level?

依然范特西╮ 提交于 2019-12-05 04:35:02

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.

Rack::Request

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

ActionDispatch::Request

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

A middleware is probably the best way to access this data. I made a simple gem for setting up a raw HTTP request/response log in Rails using the classes mentioned in the accepted answer.

https://github.com/andrhamm/marcopolo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!