-
-
Save ixth/e6a259153ba916947a79317b41b78b93 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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key:"string value" | |
int_key:22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
URL='' | |
MSG='' | |
while [ $OPTIND -le "$#" ]; do | |
if getopts "p:q:s:" OPT; then | |
case $OPT in | |
p) PROTO="$OPTARG";; | |
q) REQUEST="$OPTARG";; | |
s) RESPONSE="$OPTARG";; | |
esac | |
else | |
if [ -z "$URL" ]; then | |
URL="${!OPTIND}"; | |
elif [ -z "$MSG" ]; then | |
MSG="${!OPTIND}"; | |
else | |
echo "Unknown param: ${!OPTIND}"; | |
exit 1 | |
fi | |
((OPTIND++)) | |
fi | |
done | |
protoc --encode "$REQUEST" "$PROTO" < "$MSG" |\ | |
curl -sS "$URL" --data-binary @- |\ | |
protoc --decode "$RESPONSE" "$PROTO" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've created a command line tool specifically for this use case: protoCURL
There is also documentation for how to use the text format and how it works with JSON as well.