What is the “env” variable in Rack middleware?

前端 未结 4 841
心在旅途
心在旅途 2021-01-01 11:56

I know a Rack middleware filter is a Ruby class with an initialize and a call method. I know the call method takes an \"env\" argument. Something like this:



        
4条回答
  •  失恋的感觉
    2021-01-01 12:16

    Looking at the source code depending on which web server you have you can get different values in your env hash. I recommend only using what's in the documentation.

    Basically the env is a hash version of the request object specific to the web server. Rack does some work to give a normalized env so the middleware can behave consistently across web servers.

提交回复
热议问题