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
38 39 40 |
# File 'lib/dassets/server/request.rb', line 38 def asset_file @asset_file ||= Dassets.asset_file(asset_path) end |
#asset_path ⇒ Object
34 35 36 |
# File 'lib/dassets/server/request.rb', line 34 def asset_path @asset_path ||= path_digest_match.captures.select{ |m| !m.empty? }.join end |
#dassets_base_url ⇒ Object
21 22 23 |
# File 'lib/dassets/server/request.rb', line 21 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)
30 31 32 |
# File 'lib/dassets/server/request.rb', line 30 def for_asset_file? !!((get? || head?) && for_digested_asset? && asset_file.exists?) end |
#path_info ⇒ Object
17 18 19 |
# File 'lib/dassets/server/request.rb', line 17 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.
13 14 15 |
# File 'lib/dassets/server/request.rb', line 13 def request_method @env["REQUEST_METHOD"] end |