Sha256: 8545fc888e41720b907a342640e54391bcc8d07dfd42bc0a863e1b89542e78b8

Contents?: true

Size: 456 Bytes

Versions: 7

Compression:

Stored size: 456 Bytes

Contents

# frozen_string_literal: true

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
finapps_core-6.0.2 lib/finapps_core/middleware/request/x_tenant_id.rb
finapps_core-6.0.1 lib/finapps_core/middleware/request/x_tenant_id.rb
finapps_core-6.0.0 lib/finapps_core/middleware/request/x_tenant_id.rb
finapps_core-5.0.16 lib/finapps_core/middleware/request/x_tenant_id.rb
finapps_core-5.0.15 lib/finapps_core/middleware/request/x_tenant_id.rb
finapps_core-5.0.14 lib/finapps_core/middleware/request/x_tenant_id.rb
finapps_core-5.0.13 lib/finapps_core/middleware/request/x_tenant_id.rb