Class: Nanoc::Github::ModifyMaxAge

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/nanoc/github.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, time:) ⇒ ModifyMaxAge

Returns a new instance of ModifyMaxAge.



33
34
35
36
# File 'lib/nanoc/github.rb', line 33

def initialize(app, time:)
  @app  = app
  @time = Integer(time)
end

Instance Method Details

#call(request_env) ⇒ Object



38
39
40
41
42
# File 'lib/nanoc/github.rb', line 38

def call(request_env)
  @app.call(request_env).on_complete do |response_env|
    response_env[:response_headers][:cache_control] = "public, max-age=#{@time}, s-maxage=#{@time}"
  end
end