Sha256: 65aeb0a9d2aeb99c818b66637dbd4306298b434bdeafbceeefb4ed565d7cb6bd

Contents?: true

Size: 611 Bytes

Versions: 5

Compression:

Stored size: 611 Bytes

Contents

# Captures surrogate keys headers and collects them for passing to the client.
module FlexCommerceApi
  module JsonApiClientExtension
    class CaptureSurrogateKeysMiddleware < ::Faraday::Middleware
      def call(environment)
        @app.call(environment).on_complete do |env|
          surrogate_keys = env.response_headers['external-surrogate-key'].split(' ') if env.response_headers['external-surrogate-key']

          if surrogate_keys && Thread.current[:shift_surrogate_keys]
            Thread.current[:shift_surrogate_keys].concat(surrogate_keys)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flex_commerce_api-0.8.3 lib/flex_commerce_api/json_api_client_extension/capture_surrogate_keys_middleware.rb
flex_commerce_api-0.8.2 lib/flex_commerce_api/json_api_client_extension/capture_surrogate_keys_middleware.rb
flex_commerce_api-0.8.1 lib/flex_commerce_api/json_api_client_extension/capture_surrogate_keys_middleware.rb
flex_commerce_api-0.7 lib/flex_commerce_api/json_api_client_extension/capture_surrogate_keys_middleware.rb
flex_commerce_api-0.6.57 lib/flex_commerce_api/json_api_client_extension/capture_surrogate_keys_middleware.rb