Memo about curl / Twirp
Hello, this is memo about curl / Twirp
Environments
- go version go1.12.8 darwin/amd64
- github.com/twitchtv/twirp v5.9.0+incompatible
Case 1: argument is empty
syntax = "proto3";
package api;
import "google/protobuf/empty.proto";
service MyService {
rpc GetData(google.protobuf.Empty) returns (google.protobuf.Empty);
}
We should send {}
curl -X POST \
-H "Content-Type:application/json" \
-d "{}" \
http://localhost:8888/twirp/api.MyService/GetData | jq
Case 1: argument contains environment value
syntax = "proto3";
package api;
import "google/protobuf/empty.proto";
service MyService {
rpc GetData(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc AddData(Val) returns (google.protobuf.Empty);
}
message Val {
string value = 1;
}
export VALUE="Hello"
curl -X POST \
-H "Content-Type:application/json" \
-d "{\"value\": ${VALUE}}" \
http://localhost:8888/twirp/api.MyService/AddData | jq
Read other posts