Class: Dassets::Server::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Dassets::Server::Request
- Defined in:
- lib/dassets/server/request.rb
Defined Under Namespace
Classes: NullDigestMatch
Instance Method Summary collapse
- #asset_file ⇒ Object
- #asset_path ⇒ Object
- #dassets_base_url ⇒ Object
-
#for_asset_file? ⇒ Boolean
Determine if the request is for an asset file This will be called on every request so speed is an issue - first check if the request is a GET or HEAD (fast) - then check if for a digested asset resource (kinda fast) - then check if source exists for the digested asset (slower).
- #path_info ⇒ Object
-
#request_method ⇒ Object
The HTTP request method.
Instance Method Details
#asset_file ⇒ Object
35 36 37 |
# File 'lib/dassets/server/request.rb', line 35 def asset_file @asset_file ||= Dassets[asset_path] end |
#asset_path ⇒ Object
31 32 33 |
# File 'lib/dassets/server/request.rb', line 31 def asset_path @asset_path ||= path_digest_match.captures.select{ |m| !m.empty? }.join end |
#dassets_base_url ⇒ Object
18 19 20 |
# File 'lib/dassets/server/request.rb', line 18 def dassets_base_url Dassets.config.base_url.to_s end |
#for_asset_file? ⇒ Boolean
Determine if the request is for an asset file This will be called on every request so speed is an issue
-
first check if the request is a GET or HEAD (fast)
-
then check if for a digested asset resource (kinda fast)
-
then check if source exists for the digested asset (slower)
27 28 29 |
# File 'lib/dassets/server/request.rb', line 27 def for_asset_file? !!((get? || head?) && for_digested_asset? && asset_file.exists?) end |
#path_info ⇒ Object
14 15 16 |
# File 'lib/dassets/server/request.rb', line 14 def path_info @env['PATH_INFO'].sub(dassets_base_url, '') end |
#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.
12 |
# File 'lib/dassets/server/request.rb', line 12 def request_method; @env['REQUEST_METHOD']; end |