class Prefab::AuthInterceptor

Public Class Methods

new(api_key) click to toggle source
# File lib/prefab/auth_interceptor.rb, line 3
def initialize(api_key)
  version = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
  @client = "prefab-cloud-ruby.#{version}".freeze
  @api_key = api_key
end

Public Instance Methods

bidi_streamer(requests:, call:, method:, metadata:, &block) click to toggle source
# File lib/prefab/auth_interceptor.rb, line 21
def bidi_streamer(requests:, call:, method:, metadata:, &block)
  shared(metadata, &block)
end
client_streamer(requests:, call:, method:, metadata:, &block) click to toggle source
# File lib/prefab/auth_interceptor.rb, line 13
def client_streamer(requests:, call:, method:, metadata:, &block)
  shared(metadata, &block)
end
request_response(request:, call:, method:, metadata:, &block) click to toggle source
# File lib/prefab/auth_interceptor.rb, line 9
def request_response(request:, call:, method:, metadata:, &block)
  shared(metadata, &block)
end
server_streamer(request:, call:, method:, metadata:, &block) click to toggle source
# File lib/prefab/auth_interceptor.rb, line 17
def server_streamer(request:, call:, method:, metadata:, &block)
  shared(metadata, &block)
end
shared(metadata) { || ... } click to toggle source
# File lib/prefab/auth_interceptor.rb, line 25
def shared(metadata)
  metadata['auth'] = @api_key
  metadata['client'] = @client
  yield
end