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"`
|
2023-09-19 23:27:32 +01:00
|
|
|
TemplateStorage string `yaml:"templateStorage"`
|
2022-07-15 13:28:29 +01:00
|
|
|
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"`
|
2023-09-19 23:27:32 +01:00
|
|
|
PageSettings []PageYaml `yaml:"pageSettings"`
|
|
|
|
YmlDataFallback bool `yaml:"ymlDataFallback"`
|
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
|
|
|
|
}
|
|
|
|
}
|
2023-09-19 23:27:32 +01:00
|
|
|
|
|
|
|
func (sy ServeYaml) GetTemplateStoragePath() string {
|
|
|
|
if sy.TemplateStorage == "" || !filepath.IsAbs(sy.TemplateStorage) {
|
|
|
|
wd, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
return ""
|
|
|
|
} else {
|
|
|
|
if sy.TemplateStorage == "" {
|
|
|
|
return wd
|
|
|
|
} else {
|
|
|
|
return path.Join(wd, sy.TemplateStorage)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return sy.TemplateStorage
|
|
|
|
}
|
|
|
|
}
|