Class: Dassets::Server::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/dassets/server/request.rb

Defined Under Namespace

Classes: NullDigestMatch

Instance Method Summary collapse

Instance Method Details

#asset_fileObject



37
38
39
# File 'lib/dassets/server/request.rb', line 37

def asset_file
  @asset_file ||= Dassets.asset_file(asset_path)
end

#asset_pathObject



33
34
35
# File 'lib/dassets/server/request.rb', line 33

def asset_path
  @asset_path ||= path_digest_match.captures.select{ |m| !m.empty? }.join
end

#dassets_base_urlObject



20
21
22
# File 'lib/dassets/server/request.rb', line 20

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)

Returns:

  • (Boolean)


29
30
31
# File 'lib/dassets/server/request.rb', line 29

def for_asset_file?
  !!((get? || head?) && for_digested_asset? && asset_file.exists?)
end

#path_infoObject



16
17
18
# File 'lib/dassets/server/request.rb', line 16

def path_info
  @env["PATH_INFO"].sub(dassets_base_url, "")
end

#request_methodObject

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
13
14
# File 'lib/dassets/server/request.rb', line 12

def request_method
  @env["REQUEST_METHOD"]
end