Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.42 KB

api_grpc_gateway.md

File metadata and controls

38 lines (25 loc) · 1.42 KB

Why grpc-gateway

etcd v3 uses gRPC for its messaging protocol. The etcd project includes a gRPC-based Go client and a command line utility, etcdctl, for communicating with an etcd cluster through gRPC. For languages with no gRPC support, etcd provides a JSON grpc-gateway. This gateway serves a RESTful proxy that translates HTTP/JSON requests into gRPC messages.

Using grpc-gateway

The gateway accepts a JSON mapping for etcd's protocol buffer message definitions. Note that key and value fields are defined as byte arrays and therefore must be base64 encoded in JSON.

<<COMMENT
https://www.base64encode.org/
foo is 'Zm9v' in Base64
bar is 'YmFy'
COMMENT

curl -L http://localhost:2379/v3alpha/kv/put \
	-X POST -d '{"key": "Zm9v", "value": "YmFy"}'

curl -L http://localhost:2379/v3alpha/kv/range \
	-X POST -d '{"key": "Zm9v"}'

Swagger

Generated Swagger API definitions can be found at rpc.swagger.json.