Sha256: 01ae1abffc975c6e0744f77b2e6eb33b6f420447319b9fcae07975af1781cc26

Contents?: true

Size: 470 Bytes

Versions: 12

Compression:

Stored size: 470 Bytes

Contents

# frozen_string_literal: true

module FinAppsCore
  module Middleware
    # Adds a header to specify consumer to retrieve data for
    class XConsumerId < Faraday::Middleware
      KEY = 'X-Consumer-ID' unless defined? KEY

      def initialize(app, x_consumer_id)
        super(app)
        @x_consumer_id = x_consumer_id.to_s.strip
      end

      def call(env)
        env[:request_headers][KEY] ||= @x_consumer_id
        @app.call(env)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
finapps_core-6.0.2 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-6.0.1 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-6.0.0 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.16 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.15 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.14 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.13 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.11 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.10 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.9 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.8 lib/finapps_core/middleware/request/x_consumer_id.rb
finapps_core-5.0.7 lib/finapps_core/middleware/request/x_consumer_id.rb