config.go 952 B

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