Class: Rack::Cache::Request
- Inherits:
-
Request
- Object
- Request
- Rack::Cache::Request
- Includes:
- Headers, RequestHeaders
- Defined in:
- lib/rack/cache/request.rb
Overview
Provides access to the HTTP request. The request and original_request objects exposed by the Core caching engine are instances of this class.
Request objects respond to a variety of convenience methods, including everything defined by Rack::Request as well as the Headers and RequestHeaders modules.
Instance Method Summary collapse
-
#request_method ⇒ Object
The HTTP request method.
-
#request_method?(*methods) ⇒ Boolean
(also: #method?)
Determine if the request’s method matches any of the values provided: if request.request_method?(‘GET’, ‘POST’) …
Methods included from RequestHeaders
#headers, #if_modified_since, #if_none_match
Methods included from Headers
#cache_control, #cache_control=, #etag, #header?
Instance Method Details
#request_method ⇒ Object
The HTTP request method. This is the standard implementation of this method but is respecified here due to libraries that attempt to modify the behavior to respect POST tunnel method specifiers. We always want the real request method.
21 22 23 |
# File 'lib/rack/cache/request.rb', line 21 def request_method @env['REQUEST_METHOD'] end |
#request_method?(*methods) ⇒ Boolean Also known as: method?
Determine if the request’s method matches any of the values provided:
if request.request_method?('GET', 'POST')
...
end
30 31 32 33 |
# File 'lib/rack/cache/request.rb', line 30 def request_method?(*methods) method = request_method methods.any? { |test| test.to_s.upcase == method } end |