Sha256: 78b5ee4b0d06fece4de5997f0bc040c5c3d518ee6730a6e3be7a125f600a19c8
Contents?: true
Size: 633 Bytes
Versions: 66
Compression:
Stored size: 633 Bytes
Contents
module Pact module Consumer class CorsOriginHeaderMiddleware def initialize app, cors_enabled @app = app @cors_enabled = cors_enabled end def call env response = @app.call env if env['HTTP_X_PACT_MOCK_SERVICE'] || @cors_enabled add_cors_header env, response else response end end def shutdown @app.shutdown end private def add_cors_header env, response [response[0], response[1].merge('Access-Control-Allow-Origin' => env.fetch('HTTP_ORIGIN','*')), response[2]] end end end end
Version data entries
66 entries across 66 versions & 1 rubygems