From 6dd4fde56a5a6db9cbfebe9cb9affeac2d999ba6 Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Fri, 26 Oct 2018 13:24:30 -0700 Subject: [PATCH 1/2] Fix incorrect hash key in gRPC Ruby documentation --- docs/grpc/ruby.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/grpc/ruby.md b/docs/grpc/ruby.md index 5fcd8f56e..0a6dcfc21 100644 --- a/docs/grpc/ruby.md +++ b/docs/grpc/ruby.md @@ -128,7 +128,7 @@ macaroon = macaroon_binary.each_byte.map { |b| b.to_s(16).rjust(2,'0') }.join The simplest approach to use the macaroon is to include the metadata in each request as shown below. ```ruby -stub.get_info(Lnrpc::GetInfoRequest.new, metadata: {metadata: macaroon}) +stub.get_info(Lnrpc::GetInfoRequest.new, metadata: {macaroon: macaroon}) ``` However, this can get tiresome to do for each request. We can use gRPC interceptors to add this metadata to each request automatically. Our interceptor class would look like this. From 8103db60de5f75a363296cc0d257d003a7a34dd7 Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Fri, 26 Oct 2018 14:02:32 -0700 Subject: [PATCH 2/2] Show how macaroon interceptor can work with streaming gRPC in Ruby doc --- docs/grpc/ruby.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/grpc/ruby.md b/docs/grpc/ruby.md index 0a6dcfc21..5725707af 100644 --- a/docs/grpc/ruby.md +++ b/docs/grpc/ruby.md @@ -146,6 +146,11 @@ class MacaroonInterceptor < GRPC::ClientInterceptor metadata['macaroon'] = macaroon yield end + + def server_streamer(request:, call:, method:, metadata:) + metadata['macaroon'] = macaroon + yield + end end ```