config.go 1015 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package gateway
  2. import (
  3. "time"
  4. "github.com/zeromicro/go-zero/rest"
  5. "github.com/zeromicro/go-zero/zrpc"
  6. )
  7. type (
  8. // GatewayConf is the configuration for gateway.
  9. GatewayConf struct {
  10. rest.RestConf
  11. Upstreams []Upstream
  12. Timeout time.Duration `json:",default=5s"`
  13. }
  14. // RouteMapping is a mapping between a gateway route and an upstream rpc method.
  15. RouteMapping struct {
  16. // Method is the HTTP method, like GET, POST, PUT, DELETE.
  17. Method string
  18. // Path is the HTTP path.
  19. Path string
  20. // RpcPath is the gRPC rpc method, with format of package.service/method
  21. RpcPath string
  22. }
  23. // Upstream is the configuration for an upstream.
  24. Upstream struct {
  25. // Grpc is the target of the upstream.
  26. Grpc zrpc.RpcClientConf
  27. // ProtoSet is the file of proto set, like hello.pb
  28. ProtoSet string `json:",optional"`
  29. // Mapping is the mapping between gateway routes and Upstream rpc methods.
  30. // Keep it blank if annotations are added in rpc methods.
  31. Mapping []RouteMapping `json:",optional"`
  32. }
  33. )