gRPC
Courier calls gRPC services directly. It reads the service description from server reflection or from your .proto files, so you don’t need to install protoc.
Create a gRPC request
Section titled “Create a gRPC request”Choose gRPC from the command palette or from the menu next to New request. In a file, it looks like this:
### Say hello# @proto ./protos/greeter.proto# @import-path ./protosGRPC localhost:50051/helloworld.Greeter/SayHelloauthorization: Bearer {{token}}
{ "name": "{{who}}" }
> {% client.test("OK", () => client.assert(response.status === "OK"));%}- The request line is
GRPC host:port/package.Service/Method. - Put
grpcs://orhttps://in front of the host for TLS. Without it, the call is plaintext HTTP/2 (h2c). - Header lines are sent as metadata. Names ending in
-bintake base64 values. - The body is the request message as JSON. Client and bidirectional streams take several messages separated by
===lines.
Describe the service
Section titled “Describe the service”Courier uses one of two sources:
- Server reflection (
grpc.reflection.v1, falling back tov1alpha). This is the default. - A
.protofile, named with# @proto. Add# @import-pathlines for folders its imports live in. Use Load .proto… in the Message tab to set it.
Descriptions are cached per server or proto file in .courier/schemas/. Click Refresh to fetch them again.
Messages follow the proto3 JSON rules: 64-bit integers are strings, enums are names, and well-known types such as Timestamp, Duration and Struct use their JSON forms.
Edit the message
Section titled “Edit the message”The Message tab has:
- a method picker with search, listing every service and method with its call kind,
- a JSON editor that completes field names and enum values and flags unknown fields and bad enum values,
- Generate example message, which fills in every field.
{{variables}} and references work in metadata and messages.
Call the method
Section titled “Call the method”Press ⌘↵. Courier shows the status as its name and number, such as OK · 0 or NOT_FOUND · 5, with google.rpc.Status details when the server sends them.
- Unary replies show as foldable JSON.
- Streams show a live log of messages in and out.
- Client and bidirectional streams get a composer to send more messages, End stream to half-close, and Cancel (⌘.).
Metadata, trailers and timing (DNS, connect, TLS, first message, total) have their own tabs.
Unary and client-streaming calls use the request timeout from Settings as their deadline. Server and bidirectional streams have no deadline in the app.
The connection uses the same proxy and TLS code as HTTP, so TLS verification and extra CA certificates apply.
Test and reuse calls
Section titled “Test and reuse calls”- The
> {% %}handler runs on the reply, or on each message of a server or bidirectional stream, withresponse.statusset to the status name. - Unary calls are kept in history, so run diff and
{{name.response.body.$…}}references work. - Code exports a
grpcurlcommand. courier runruns gRPC requests and fails on a non-OK status unless--fail-onleaves outgrpc.