github.com/hduhelp/go-zero@v1.4.3/gateway/config.go (about) 1 package gateway 2 3 import ( 4 "time" 5 6 "github.com/hduhelp/go-zero/rest" 7 "github.com/hduhelp/go-zero/zrpc" 8 ) 9 10 type ( 11 // GatewayConf is the configuration for gateway. 12 GatewayConf struct { 13 rest.RestConf 14 Upstreams []Upstream 15 Timeout time.Duration `json:",default=5s"` 16 } 17 18 // RouteMapping is a mapping between a gateway route and an upstream rpc method. 19 RouteMapping struct { 20 // Method is the HTTP method, like GET, POST, PUT, DELETE. 21 Method string 22 // Path is the HTTP path. 23 Path string 24 // RpcPath is the gRPC rpc method, with format of package.service/method 25 RpcPath string 26 } 27 28 // Upstream is the configuration for an upstream. 29 Upstream struct { 30 // Name is the name of the upstream. 31 Name string `json:",optional"` 32 // Grpc is the target of the upstream. 33 Grpc zrpc.RpcClientConf 34 // ProtoSets is the file list of proto set, like [hello.pb]. 35 // if your proto file import another proto file, you need to write multi-file slice, 36 // like [hello.pb, common.pb]. 37 ProtoSets []string `json:",optional"` 38 // Mappings is the mapping between gateway routes and Upstream rpc methods. 39 // Keep it blank if annotations are added in rpc methods. 40 Mappings []RouteMapping `json:",optional"` 41 } 42 )