没有固定请求结构的protobuf webhook

问题描述 投票:0回答:1

我使用

Golang
作为我的后端,使用
proto3
作为我的 API 定义。我有
grpc-gateway
来支持 http 和 grpc。

我的用例是拥有一个 webhook API,它可以获取一些有效负载并对其进行处理。我无法控制客户端,也无法确定有效负载结构。

如何定义我的请求对象?

示例:

service RepoService {
  rpc PostGitPR(PostGitPREventRequest) returns (PostGitPREventResponse) {
    option (google.api.http) = {
      post: "/git/pr/event"
      body: "*"
    };
  }

我使用

any.proto
还是
[]byte
?我不确定两者都会起作用。

go protocol-buffers proto3 github-webhook
1个回答
0
投票

如果无法预测有效负载,您可以使用

google.api.HttpBody
作为原型文件中的请求对象。请参阅:https://github.com/googleapis/googleapis/blob/master/google/api/httpbody.proto

© www.soinside.com 2019 - 2024. All rights reserved.