I found a solution which actually imposes two steps:
1. hook on the generated gateway forwarding methods to flag certain data to convert to simple json
2. intercept the http multiplexer to catch the flagged stream and do the work.
1.1 create (**) a file in the apifolder /projectname/api/testapi/{ test.proto, **test_reflag.go**, test.pb.go, test.pb.gw.go}
1.2 file content:
func forwardSimpleTest(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, req *http.Request, resp proto.Message, opts ...func(context.Context, http.ResponseWriter, proto.Message) error) {
w.Header().Set("json", "simplify") //flagged <<<<
runtime.ForwardResponseMessage(ctx, mux, marshaler, w, req, resp, opts...)
}
func init() {
forward_MyTest_GetSimpleTests_0 = forwardSimpleTest //... for all calls which need to be flagged
}
2. hook the interceptor into the Responsewriter where I detect the simplified and rewrite the JSON structure from:
{
simple:{
sad that it is not possible with the grpc gateway nor configurable with the protobuf library...
Anyway, if somebody has the same issue this is a nice and fast workaround