mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
Merge pull request #2107 from vwoo/grpc-ruby-doc-macaroon
gRPC ruby doc updates
This commit is contained in:
commit
08c2ee05f6
1 changed files with 6 additions and 1 deletions
|
@ -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.
|
The simplest approach to use the macaroon is to include the metadata in each request as shown below.
|
||||||
|
|
||||||
```ruby
|
```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.
|
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.
|
||||||
|
@ -146,6 +146,11 @@ class MacaroonInterceptor < GRPC::ClientInterceptor
|
||||||
metadata['macaroon'] = macaroon
|
metadata['macaroon'] = macaroon
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def server_streamer(request:, call:, method:, metadata:)
|
||||||
|
metadata['macaroon'] = macaroon
|
||||||
|
yield
|
||||||
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue