github.com/lingyao2333/mo-zero@v1.4.1/rest/config.go (about)

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