config.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package rest
  2. import (
  3. "time"
  4. "github.com/tal-tech/go-zero/core/service"
  5. )
  6. type (
  7. // A PrivateKeyConf is a private key config.
  8. PrivateKeyConf struct {
  9. Fingerprint string
  10. KeyFile string
  11. }
  12. // A SignatureConf is a signature config.
  13. SignatureConf struct {
  14. Strict bool `json:",default=false"`
  15. Expiry time.Duration `json:",default=1h"`
  16. PrivateKeys []PrivateKeyConf
  17. }
  18. // A RestConf is a http service config.
  19. // Why not name it as Conf, because we need to consider usage like:
  20. // type Config struct {
  21. // zrpc.RpcConf
  22. // rest.RestConf
  23. // }
  24. // if with the name Conf, there will be two Conf inside Config.
  25. RestConf struct {
  26. service.ServiceConf
  27. Host string `json:",default=0.0.0.0"`
  28. Port int
  29. CertFile string `json:",optional"`
  30. KeyFile string `json:",optional"`
  31. Verbose bool `json:",optional"`
  32. MaxConns int `json:",default=10000"`
  33. MaxBytes int64 `json:",default=1048576,range=[0:33554432]"`
  34. // milliseconds
  35. Timeout int64 `json:",default=3000"`
  36. CpuThreshold int64 `json:",default=900,range=[0:1000]"`
  37. Signature SignatureConf `json:",optional"`
  38. }
  39. )