Skip to content

Instantly share code, notes, and snippets.

@rogersguedes
Forked from alexeypegov/proto.msg
Last active May 9, 2019 12:51
Show Gist options
  • Save rogersguedes/80c3a5a0b299308660111394e2614cfa to your computer and use it in GitHub Desktop.
Save rogersguedes/80c3a5a0b299308660111394e2614cfa to your computer and use it in GitHub Desktop.
ProtoBuffers debug with CURL. ProtoBuffers should be installed first: "yum install protobuf" or "brew install protobuf".
key:"string value"
int_key:22
#!/bin/bash
#### Decode
# protoc \
# --proto_path=<path-to-folder-containing-imported-.proto-files> \
# --decode <msg-definition-name> \
# <path-to-.proto-file> < <path-to-binary-encoded-msg-file>
#### Encode
# protoc \
# --proto_path=<path-to-folder-containing-imported-.proto-files> \
# --encode <msg-definition-name> \
# example_msg.proto < <path-to-clear-text-msg-file> > <path-to-binary-encoded-msg-file>
URL=full_method_url # i.e. "http://server.com/my/method" (without quotes)
REQUEST=request_message_name # i.e. "Request"
RESPONSE=response_message_name # i.e. "Response"
PROTO=proto_file_name # i.e. "./Protocol.proto"
cat proto.msg | protoc --encode $REQUEST $PROTO | curl -sS -X POST --data-binary @- $URL | protoc --decode $RESPONSE $PROTO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment