config.go 1.2 KB

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