Inject macaroon metadata on all grpc calls

This commit is contained in:
bumi 2019-02-19 16:08:31 +01:00
parent e34cd1de00
commit 9ec6414a2b
1 changed files with 7 additions and 1 deletions

View File

@ -6,11 +6,17 @@ module Lnrpc
@macaroon = macaroon_hex
end
def request_response(request:, call:, method:, metadata:)
def inject_macaroon_metadata(request:, call:, method:, metadata:)
if !metadata.has_key?('macaroon') && !metadata.has_key?(:macaroon)
metadata[:macaroon] = @macaroon
end
yield
end
alias :request_response :inject_macaroon_metadata
alias :client_streamer :inject_macaroon_metadata
alias :server_streamer :inject_macaroon_metadata
alias :bidi_streamer :inject_macaroon_metadata
end
end