feat: add server name and version to all responses

This is inline with other Subsonic compatible servers, like funkwhale, madsonic, ampache...
This commit is contained in:
Deluan
2020-01-30 14:43:24 -05:00
parent 482350c076
commit 90a1e6d213
47 changed files with 76 additions and 71 deletions
+2 -18
View File
@@ -4,33 +4,17 @@ import (
"fmt"
"strings"
"github.com/deluan/navidrome/consts"
"github.com/deluan/navidrome/static"
)
var (
// This will be set in build time. If not, version will be set to "dev"
gitTag string
gitSha string
)
// Formats:
// dev
// v0.2.0 (5b84188)
// master (9ed35cb)
func getVersion() string {
if gitSha == "" {
return "dev"
}
return fmt.Sprintf("%s (%s)", gitTag, gitSha)
}
func getBanner() string {
data, _ := static.Asset("banner.txt")
return strings.TrimSuffix(string(data), "\n")
}
func ShowBanner() {
version := "Version: " + getVersion()
version := "Version: " + consts.Version()
padding := strings.Repeat(" ", 52-len(version))
fmt.Printf("%s%s%s\n\n", getBanner(), padding, version)
}