gRPC scripting is a Beta feature. Enable it under Preferences → Beta → gRPC Scripting before the Script tab appears on gRPC requests. See Preferences.
Lifecycle hooks
Open a gRPC request and select the Script tab. The tab contains one editor per hook:
For a unary call, each hook runs once. For streaming calls, the message hooks run once per message sent or received.
The bru.grpc API
gRPC scripts use the same bru object as HTTP scripts for variables, assertions, and utilities. Instead of the req and res globals, the request and response models live under bru.grpc.
bru.grpc.request
bru.grpc.response
Available in the After Message Receive and After Call End hooks.
In After Message Receive the call is still open, so
statusCode, statusText, duration, and trailers are not yet known and read as undefined or empty. They are complete in After Call End.Metadata methods
metadata on the request and metadata and trailers on the response share the same list API. Keys are matched case-insensitively.
Write methods work only on
bru.grpc.request.metadata in the Before Call Start hook.
Message methods
messages on the request and response is a read-only list.
Each message is a
{ data, timestamp } object, where data is the decoded message payload.