Sha256: 1e08f07b63c5b252488c0311fa8f112bdabc65ba59f4c190442ed2a2761a4b0b

Contents?: true

Size: 844 Bytes

Versions: 6

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true
module Prefab
  class AuthInterceptor < GRPC::ClientInterceptor
    def initialize(api_key)
      version = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
      @client = "prefab-cloud-ruby.#{version}".freeze
      @api_key = api_key
    end

    def request_response(request:, call:, method:, metadata:, &block)
      shared(metadata, &block)
    end

    def client_streamer(requests:, call:, method:, metadata:, &block)
      shared(metadata, &block)
    end

    def server_streamer(request:, call:, method:, metadata:, &block)
      shared(metadata, &block)
    end

    def bidi_streamer(requests:, call:, method:, metadata:, &block)
      shared(metadata, &block)
    end

    def shared(metadata)
      metadata['auth'] = @api_key
      metadata['client'] = @client
      yield
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
prefab-cloud-ruby-0.16.0 lib/prefab/auth_interceptor.rb
prefab-cloud-ruby-0.15.0 lib/prefab/auth_interceptor.rb
prefab-cloud-ruby-0.14.0 lib/prefab/auth_interceptor.rb
prefab-cloud-ruby-0.13.3 lib/prefab/auth_interceptor.rb
prefab-cloud-ruby-0.13.2 lib/prefab/auth_interceptor.rb
prefab-cloud-ruby-0.13.0 lib/prefab/auth_interceptor.rb