From 5348375b99797c82be89a3f022687b17468890b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=AE=88=E8=B6=8A?= Date: Wed, 27 Jul 2022 09:10:23 +0800 Subject: [PATCH] support mulitple protoset files (#2190) --- gateway/config.go | 5 +++-- gateway/server.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gateway/config.go b/gateway/config.go index a547d2aef5c6..92ac63d0725b 100644 --- a/gateway/config.go +++ b/gateway/config.go @@ -29,8 +29,9 @@ type ( Upstream struct { // Grpc is the target of the upstream. Grpc zrpc.RpcClientConf - // ProtoSet is the file of proto set, like hello.pb - ProtoSet string `json:",optional"` + // ProtoSets is the file list of proto set, like [hello.pb] + // if your proto file import another proto file, you need to write multi-file slice, like [hello.pb, common.pb] + ProtoSets []string `json:",optional"` // Mapping is the mapping between gateway routes and Upstream rpc methods. // Keep it blank if annotations are added in rpc methods. Mapping []RouteMapping `json:",optional"` diff --git a/gateway/server.go b/gateway/server.go index a15b17da3576..80a44f0a23ac 100644 --- a/gateway/server.go +++ b/gateway/server.go @@ -142,8 +142,8 @@ func (s *Server) createDescriptorSource(cli zrpc.Client, up Upstream) (grpcurl.D var source grpcurl.DescriptorSource var err error - if len(up.ProtoSet) > 0 { - source, err = grpcurl.DescriptorSourceFromProtoSets(up.ProtoSet) + if len(up.ProtoSets) > 0 { + source, err = grpcurl.DescriptorSourceFromProtoSets(up.ProtoSets...) if err != nil { return nil, err }