config.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. CertFile string `json:",optional"`
  27. KeyFile string `json:",optional"`
  28. Verbose bool `json:",optional"`
  29. MaxConns int `json:",default=10000"`
  30. MaxBytes int64 `json:",default=1048576,range=[0:33554432]"`
  31. // milliseconds
  32. Timeout int64 `json:",default=3000"`
  33. CpuThreshold int64 `json:",default=900,range=[0:1000]"`
  34. Signature SignatureConf `json:",optional"`
  35. }
  36. )