class Rack::Jspm

Constants

VERSION

Attributes

app[R]
options[R]

Public Class Methods

new(app, options = {}) click to toggle source
# File lib/rack/jspm.rb, line 8
def initialize(app, options = {})
  @app = app
  @options = { max_age: 3600 }.merge(options)
end

Public Instance Methods

cache_control() click to toggle source
# File lib/rack/jspm.rb, line 26
def cache_control
  { 'Cache-Control' => "max-age=#{max_age}, public" }
end
call(env) click to toggle source
# File lib/rack/jspm.rb, line 13
def call(env)
  status, headers, body = @app.call(env)
  case env['PATH_INFO']
    when %r{/jspm_packages/[^/]+/}
      headers = headers.merge(cache_control)
  end
  [status, headers, body]
end
max_age() click to toggle source
# File lib/rack/jspm.rb, line 22
def max_age
  options.fetch(:max_age)
end