go-zero/rest/config.go

42 lines
1.0 KiB
Go
Raw Normal View History

2020-07-31 11:14:48 +08:00
package rest
2020-07-26 17:09:05 +08:00
import (
"time"
2020-08-08 16:40:10 +08:00
"github.com/tal-tech/go-zero/core/service"
2020-07-26 17:09:05 +08:00
)
type (
PrivateKeyConf struct {
Fingerprint string
KeyFile string
}
SignatureConf struct {
Strict bool `json:",default=false"`
Expiry time.Duration `json:",default=1h"`
PrivateKeys []PrivateKeyConf
}
2020-10-29 17:44:51 +08:00
// Why not name it as Conf, because we need to consider usage like:
2020-07-31 11:14:48 +08:00
// type Config struct {
2020-09-18 11:41:52 +08:00
// zrpc.RpcConf
2020-07-31 11:45:16 +08:00
// rest.RestConf
2020-07-31 11:14:48 +08:00
// }
// if with the name Conf, there will be two Conf inside Config.
2020-07-31 11:45:16 +08:00
RestConf struct {
2020-07-26 17:09:05 +08:00
service.ServiceConf
Host string `json:",default=0.0.0.0"`
Port int
2020-10-29 17:44:51 +08:00
CertFile string `json:",optional"`
KeyFile string `json:",optional"`
Verbose bool `json:",optional"`
MaxConns int `json:",default=10000"`
MaxBytes int64 `json:",default=1048576,range=[0:33554432]"`
2020-07-26 17:09:05 +08:00
// milliseconds
Timeout int64 `json:",default=3000"`
CpuThreshold int64 `json:",default=900,range=[0:1000]"`
Signature SignatureConf `json:",optional"`
}
)