Sha256: f9be1b87dfaa51039602c936c86a306ef5da86f5c76650cc5656557714a965cb

Contents?: true

Size: 839 Bytes

Versions: 4

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true
module Prefab
  class AuthInterceptor < GRPC::ClientInterceptor
    VERSION = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
    CLIENT = "prefab-cloud-ruby.#{VERSION}".freeze

    def initialize(api_key)
      @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

4 entries across 4 versions & 1 rubygems

Version Path
prefab-cloud-ruby-0.20.0 lib/prefab/auth_interceptor.rb
prefab-cloud-ruby-0.19.0 lib/prefab/auth_interceptor.rb
prefab-cloud-ruby-0.18.0 lib/prefab/auth_interceptor.rb
prefab-cloud-ruby-0.17.0 lib/prefab/auth_interceptor.rb