我们使用codefirst protobuf-net方法开发了grpc服务。我们如何使用 grpc-web 从 javascript 调用这些服务?如果我们没有 .proto 文件,我们如何生成 grpc javascript 客户端代码?
谢谢
参考 https://protobuf-net.github.io/protobuf-net.Grpc/createProtoFile 将您的 codefirst 文件转换为 protobuf 文件。像这样,使用
protobuf-net.Reflection
包:
var generator = new SchemaGenerator
{
ProtoSyntax = ProtoSyntax.Proto3
};
var schema = generator.GetSchema<ICalculator>(); // there is also a non-generic overload that takes Type
using (var writer = new System.IO.StreamWriter("services.proto"))
{
await writer.WriteAsync(schema);
}