2022-07-14 17:18:08 +01:00
|
|
|
package conf
|
|
|
|
|
2022-07-16 16:01:53 +01:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2022-07-14 17:18:08 +01:00
|
|
|
type ServeYaml struct {
|
2022-07-15 13:28:29 +01:00
|
|
|
DataStorage string `yaml:"dataStorage"`
|
|
|
|
Domains []string `yaml:"domains"`
|
|
|
|
RangeSupported bool `yaml:"rangeSupported"`
|
2022-07-16 00:53:50 +01:00
|
|
|
EnableGoInfoPage bool `yaml:"enableGoInfoPage"`
|
2022-07-15 13:28:29 +01:00
|
|
|
CacheSettings CacheSettingsYaml `yaml:"cacheSettings"`
|
2022-07-14 17:18:08 +01:00
|
|
|
}
|
2022-07-16 16:01:53 +01:00
|
|
|
|
|
|
|
func (sy ServeYaml) GetDomainString() string {
|
|
|
|
if len(sy.Domains) == 0 {
|
|
|
|
return "all"
|
|
|
|
} else {
|
|
|
|
return strings.Join(sy.Domains, " ")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sy ServeYaml) GetDataStoragePath() string {
|
|
|
|
if sy.DataStorage == "" || !filepath.IsAbs(sy.DataStorage) {
|
|
|
|
wd, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
return ""
|
|
|
|
} else {
|
|
|
|
if sy.DataStorage == "" {
|
|
|
|
return wd
|
|
|
|
} else {
|
|
|
|
return path.Join(wd, sy.DataStorage)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return sy.DataStorage
|
|
|
|
}
|
|
|
|
}
|