passing request header information to app.get
Is there a way to pass request information, such as HOST header value, on to app.get?
My application requires that a particular host is present, so when I call it normally like this:
app.get("foo")
Specifically, I want to override the
request.env["HTTP_HOST"]
value.开发者_StackOverflow
tia
As per this answer:
The method docs for .get are here: http://api.rubyonrails.org/classes/ActionDispatch/Integration/RequestHelpers.html#method-i-get
You can do something like:
app.get('/foo', nil, {'HTTP_HOST' => "bar.com"})
I'm not sure this help... I've seen code like the following:
app.call({
"HTTP_HOST"=>"...",
"SCRIPT_NAME" => "",
"PATH_INFO"=>"/lala/#{lala_id}/",
"QUERY_STRING" => "",
"SERVER_NAME" => "",
"SERVER_PORT" => "80",
"REQUEST_METHOD"=>"GET",
"rack.input" => StringIO.new
})
You might be able to still use .get
and just pass HTTP_HOST as an option like above?
精彩评论