Skip to content

Instantly share code, notes, and snippets.

@ixth
Forked from alexeypegov/proto.msg
Last active April 27, 2022 08:43
Show Gist options
  • Save ixth/e6a259153ba916947a79317b41b78b93 to your computer and use it in GitHub Desktop.
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".
key:"string value"
int_key:22
#!/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"
@GollyTicker
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment