I implemented grpc server with reversed http proxy gateway as per numerous examples and it works fine. I have simple protofile like
syntax = "proto3";
package altconfig;
option go_package = "/proto";
import "google/api/annotations.proto";
service ConfigService {
rpc CreateConfig (Config) returns (Config) {
option (google.api.http) = {
post: "/api/v1/config"
body: "*"
};
}
}
message Config {
uint32 id = 1;
string name = 2;
}
I have compilled protobuf stubs I have workable code in main.go that starts grpc server, client connection and http server
my function to implement CreateConfig just prints serialized object:
func (s *server) CreateConfig(ctx context.Context, in *con.Config) (*con.Config, error) {
log.Println(in)
return in, nil
}
When I do POST request in postman with JSON body:
{
"id": 33333,
"name": "paprika"
}
I get empty response
{
"id": 0,
"name": ""
}
I exepect to get data from the request body in POST request
My curl request >curl -d '{"id":3,"name":"paprika"}' -H "Content-Type: application/json" -X POST http://localhost:8081/api/v1/config returns log {"code":3,"message":"invalid character '\'' looking for beginning of value","details":[]}
Does anybody knows what's the reason, how to solve it and get in response the protobuf Config message