Using Server Reflection

1. Registering Reflection Service

Example: Enable reflection (Go)

import "google.golang.org/grpc/reflection"
reflection.Register(srv)
EffectDetail
Exposesgrpc.reflection.v1.ServerReflection
Toolinggrpcurl, Postman, Evans can call without .proto files

2. Using grpc_cli Tool

CommandPurpose
grpc_cli ls localhost:50051List services
grpc_cli ls localhost:50051 user.v1.UserService -lList methods
grpc_cli call localhost:50051 GetUser 'id:"u1"'Invoke

3. Listing Services

Example: grpcurl list

grpcurl -plaintext localhost:50051 list
grpcurl -plaintext localhost:50051 list user.v1.UserService

4. Describing Service Types

CommandPurpose
grpcurl ... describe user.v1.UserServiceService definition
grpcurl ... describe user.v1.UserMessage schema

5. Calling Methods via CLI

Example: grpcurl invoke

grpcurl -plaintext \
  -H "authorization: Bearer $TOK" \
  -d '{"id":"u1"}' \
  localhost:50051 user.v1.UserService/GetUser

6. Using grpcurl Tool

FlagPurpose
-plaintextNo TLS
-insecureTLS without verification
-dJSON payload (@file.json)
-HSet header
-import-path / -protoUse without reflection

7. Discovering Service Schema

UseDetail
Postman gRPCAuto-imports via reflection
Codegen on the flyDynamic clients without .proto checked in

8. Disabling Reflection in Production

ReasonMitigation
Schema leakDisable on public services
CompromiseGate behind admin port + auth
Build flagConditional register at startup

9. Using Postman with Reflection

StepDetail
Create gRPC requestSet URL + check "Use reflection"
Pick methodDropdown populated from reflection
SendAuto-generated form for request fields

10. Implementing Custom Reflection

Use caseDetail
Filter methodsHide admin-only RPCs from public reflection
Custom registryPass selective protoregistry.Files