class Rack::Manifest
Constants
- FILE_PATH
- VERSION
Public Class Methods
new(app)
click to toggle source
# File lib/rack/manifest.rb, line 19 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/manifest.rb, line 23 def call(env) if env['PATH_INFO'] == '/manifest.json' manifest = load_yaml(FILE_PATH) json = JSON.generate(manifest) etag = digest(json) return [304, {}, []] if env['HTTP_IF_NONE_MATCH'] == etag [ 200, { 'Content-Type' => 'application/json', 'Etag' => etag, 'Content-Length' => json.length.to_s }, [json] ] else @app.call(env) end end
load_yaml(path)
click to toggle source
# File lib/rack/manifest.rb, line 14 def load_yaml path YAML.load(ERB.new(File.read(path)).result) end
Private Instance Methods
digest(str)
click to toggle source
# File lib/rack/manifest.rb, line 44 def digest(str) Digest::MD5.hexdigest(str) end