feat(qs2) add qs2 framework

This commit is contained in:
hexxa 2020-12-05 10:30:03 +08:00
parent 6ae65fe09b
commit 83100007e3
33 changed files with 2934 additions and 60 deletions

49
src/server/config.go Normal file
View file

@ -0,0 +1,49 @@
package server
type FSConfig struct {
Root string `json:"root"`
OpensLimit int `json:"opensLimit"`
OpenTTL int `json:"openTTL"`
}
type Secrets struct {
TokenSecret string `json:"tokenSecret" cfg:"env"`
}
type ServerCfg struct {
ProdMode bool `json:"prodMode"`
Addr string `json:"addr"`
ReadTimeout int `json:"readTimeout"`
WriteTimeout int `json:"writeTimeout"`
MaxHeaderBytes int `json:"maxHeaderBytes"`
}
type Config struct {
Fs *FSConfig `json:"fs"`
Secrets *Secrets `json:"secrets"`
Server *ServerCfg `json:"server"`
}
func NewEmptyConfig() *Config {
return &Config{}
}
func NewDefaultConfig() *Config {
return &Config{
Fs: &FSConfig{
Root: ".",
OpensLimit: 128,
OpenTTL: 60, // 1 min
},
Secrets: &Secrets{
TokenSecret: "",
},
Server: &ServerCfg{
ProdMode: true,
Addr: "127.0.0.1:8888",
ReadTimeout: 2000,
WriteTimeout: 2000,
MaxHeaderBytes: 512,
},
}
}