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



35
36
37
# File 'lib/dassets/server/request.rb', line 35

def asset_file
  @asset_file ||= Dassets[asset_path]
end

#asset_pathObject



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_urlObject



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)

Returns:

  • (Boolean)


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_infoObject



14
15
16
# File 'lib/dassets/server/request.rb', line 14

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

def request_method; @env['REQUEST_METHOD']; end