instance method
fetch
Ruby on Rails 5.2.8.1
Since v4.0.13Signature
fetch(key, default = DEFAULT)
Returns the value for the given key mapped to @env.
If the key is not found and an optional code block is not provided, raises a KeyError exception.
If the code block is provided, then it will be run and its result returned.
Parameters
-
keyreq -
defaultopt = DEFAULT
Source
# File actionpack/lib/action_dispatch/http/headers.rb, line 87
def fetch(key, default = DEFAULT)
@req.fetch_header(env_name(key)) do
return default unless default == DEFAULT
return yield if block_given?
raise KeyError, key
end
end
Defined in actionpack/lib/action_dispatch/http/headers.rb line 87
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Http::Headers