class FlexCommerceApi::JsonApiClientExtension::CaptureSurrogateKeysMiddleware

Public Instance Methods

call(environment) click to toggle source
# File lib/flex_commerce_api/json_api_client_extension/capture_surrogate_keys_middleware.rb, line 5
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