Class: Authzed::GrpcUtil::BearerToken
- Inherits:
-
GRPC::ClientInterceptor
- Object
- GRPC::ClientInterceptor
- Authzed::GrpcUtil::BearerToken
- Defined in:
- lib/grpcutil/bearer_token.rb
Constant Summary collapse
- AUTHORIZATION_HEADER =
'authorization'
- SCHEMA =
'Bearer'
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil) ⇒ Object
Intercept a BiDi streaming call.
-
#client_streamer(requests: nil, call: nil, method: nil, metadata: nil) ⇒ Object
Intercept a client streaming call.
-
#initialize(token:) ⇒ BearerToken
constructor
A new instance of BearerToken.
-
#request_response(request: nil, call: nil, method: nil, metadata: nil) ⇒ Object
Intercept a unary request response call.
-
#server_streamer(request: nil, call: nil, method: nil, metadata: nil) ⇒ Object
Intercept a server streaming call.
Constructor Details
#initialize(token:) ⇒ BearerToken
Returns a new instance of BearerToken.
12 13 14 |
# File 'lib/grpcutil/bearer_token.rb', line 12 def initialize(token:) @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
10 11 12 |
# File 'lib/grpcutil/bearer_token.rb', line 10 def token @token end |
Instance Method Details
#bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil) ⇒ Object
Intercept a BiDi streaming call
63 64 65 66 |
# File 'lib/grpcutil/bearer_token.rb', line 63 def bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil) [AUTHORIZATION_HEADER] = bearer_token_header yield end |
#client_streamer(requests: nil, call: nil, method: nil, metadata: nil) ⇒ Object
Intercept a client streaming call
37 38 39 40 |
# File 'lib/grpcutil/bearer_token.rb', line 37 def client_streamer(requests: nil, call: nil, method: nil, metadata: nil) [AUTHORIZATION_HEADER] = bearer_token_header yield end |
#request_response(request: nil, call: nil, method: nil, metadata: nil) ⇒ Object
Intercept a unary request response call
24 25 26 27 |
# File 'lib/grpcutil/bearer_token.rb', line 24 def request_response(request: nil, call: nil, method: nil, metadata: nil) [AUTHORIZATION_HEADER] = bearer_token_header yield end |
#server_streamer(request: nil, call: nil, method: nil, metadata: nil) ⇒ Object
Intercept a server streaming call
50 51 52 53 |
# File 'lib/grpcutil/bearer_token.rb', line 50 def server_streamer(request: nil, call: nil, method: nil, metadata: nil) [AUTHORIZATION_HEADER] = bearer_token_header yield end |