Skip to content

Commit

Permalink
feat: add no-cache header
Browse files Browse the repository at this point in the history
PACT-1499
  • Loading branch information
vwong authored Dec 6, 2023
1 parent add6b29 commit 9a63732
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/pact_broker/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require "rack/pact_broker/configurable_make_it_later"
require "rack/pact_broker/no_auth"
require "rack/pact_broker/reset_thread_data"
require "rack/pact_broker/add_cache_header"
require "rack/pact_broker/add_vary_header"
require "rack/pact_broker/use_when"
require "rack/pact_broker/application_context"
Expand Down Expand Up @@ -183,6 +184,7 @@ def configure_middleware
@app_builder.use Rack::PactBroker::InvalidUriProtection
@app_builder.use Rack::PactBroker::ResetThreadData
@app_builder.use Rack::PactBroker::AddPactBrokerVersionHeader
@app_builder.use Rack::PactBroker::AddCacheHeader
@app_builder.use Rack::PactBroker::AddVaryHeader
@app_builder.use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js", "/javascripts", "/images"], :root => PactBroker.project_root.join("public")
@app_builder.use Rack::Static, :urls => ["/favicon.ico"], :root => PactBroker.project_root.join("public/images"), header_rules: [[:all, {"Content-Type" => "image/x-icon"}]]
Expand Down
14 changes: 14 additions & 0 deletions lib/rack/pact_broker/add_cache_header.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Rack
module PactBroker
class AddCacheHeader
def initialize app
@app = app
end

def call(env)
status, headers, body = @app.call(env)
[status, { "Cache-Control" => "no-cache" }.merge(headers || {}), body]
end
end
end
end

0 comments on commit 9a63732

Please sign in to comment.