Add version string to config endpoint
This commit is contained in:
parent
85cec76445
commit
1f51ef9668
@ -24,6 +24,7 @@ type config struct {
|
|||||||
WebServerPort int `yaml:"webServerPort"`
|
WebServerPort int `yaml:"webServerPort"`
|
||||||
S3 s3 `yaml:"s3"`
|
S3 s3 `yaml:"s3"`
|
||||||
InstanceDetails InstanceDetails `yaml:"instanceDetails"`
|
InstanceDetails InstanceDetails `yaml:"instanceDetails"`
|
||||||
|
VersionInfo string `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstanceDetails defines the user-visible information about this particular instance.
|
// InstanceDetails defines the user-visible information about this particular instance.
|
||||||
@ -35,6 +36,7 @@ type InstanceDetails struct {
|
|||||||
Tags []string `yaml:"tags" json:"tags"`
|
Tags []string `yaml:"tags" json:"tags"`
|
||||||
SocialHandles []socialHandle `yaml:"socialHandles" json:"socialHandles"`
|
SocialHandles []socialHandle `yaml:"socialHandles" json:"socialHandles"`
|
||||||
ExtraInfoFile string `yaml:"extraUserInfoFileName" json:"extraUserInfoFileName"`
|
ExtraInfoFile string `yaml:"extraUserInfoFileName" json:"extraUserInfoFileName"`
|
||||||
|
Version string `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type socialHandle struct {
|
type socialHandle struct {
|
||||||
@ -142,12 +144,14 @@ func (c *config) verifySettings() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Load tries to load the configuration file
|
//Load tries to load the configuration file
|
||||||
func Load(filePath string) error {
|
func Load(filePath string, versionInfo string) error {
|
||||||
Config = new(config)
|
Config = new(config)
|
||||||
|
|
||||||
if err := Config.load(filePath); err != nil {
|
if err := Config.load(filePath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config.VersionInfo = versionInfo
|
||||||
|
|
||||||
return Config.verifySettings()
|
return Config.verifySettings()
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
func GetWebConfig(w http.ResponseWriter, r *http.Request) {
|
func GetWebConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
middleware.EnableCors(&w)
|
middleware.EnableCors(&w)
|
||||||
|
|
||||||
config := config.Config.InstanceDetails
|
configuration := config.Config.InstanceDetails
|
||||||
|
configuration.Version = config.Config.VersionInfo
|
||||||
json.NewEncoder(w).Encode(config)
|
json.NewEncoder(w).Encode(configuration)
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -34,7 +34,7 @@ func main() {
|
|||||||
logrus.SetReportCaller(true)
|
logrus.SetReportCaller(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := config.Load(*configFile); err != nil {
|
if err := config.Load(*configFile, getVersion()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ async function setupApp() {
|
|||||||
app.summary = config.summary && addNewlines(config.summary);
|
app.summary = config.summary && addNewlines(config.summary);
|
||||||
app.tags = config.tags;
|
app.tags = config.tags;
|
||||||
app.title = config.title;
|
app.title = config.title;
|
||||||
app.appVersion = config.appVersion;
|
app.appVersion = config.version;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user