Sha256: b3c826ea996a5cb885a053c0aff89c894ac877222e15f4621761eda840774cca
Contents?: true
Size: 723 Bytes
Versions: 6
Compression:
Stored size: 723 Bytes
Contents
%w{ rack rack/utils }.each { |m| require m } module Murlsh # Rack middleware to set a far future expires header for urls that match # patterns. class FarFutureExpires def initialize(app, options={}) @app = app @patterns = options[:patterns] ? [*options[:patterns]] : [] @future = options[:future] || 'Wed, 22 Jun 2019 20:07:00 GMT' end def call(env) status, headers, body = @app.call(env) req = Rack::Request.new(env) headers = Rack::Utils::HeaderHash.new(headers) @patterns.each do |pattern| if pattern.match(req.path) headers['Expires'] = @future break end end [status, headers, body] end end end
Version data entries
6 entries across 6 versions & 1 rubygems