webcmd: external versioning

This commit is contained in:
mappu 2017-03-25 16:28:25 +13:00
parent 048bf09c94
commit a36a293dfa
2 changed files with 11 additions and 1 deletions

4
App.go
View File

@ -10,6 +10,8 @@ import (
"sync"
)
var APP_VERSION string = "x.x.x" // Overridden by makefile
type App struct {
cfg AppConfig
@ -44,7 +46,7 @@ func NewAppFromConfig(cfg AppConfig) *App {
}
func (this *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "webcmd/1.0")
w.Header().Set("Server", "webcmd/"+APP_VERSION)
if r.Method == "GET" {
if r.URL.Path == "/" {

View File

@ -2,15 +2,23 @@ package main
import (
"flag"
"fmt"
"log"
"os"
"code.ivysaur.me/webcmd"
)
func main() {
confPath := flag.String("config", "webcmd.conf", "Path to configuration file")
versionFlag := flag.Bool("version", false, "Display version number and exit")
flag.Parse()
if *versionFlag {
fmt.Println("webcmd/" + webcmd.APP_VERSION)
os.Exit(0)
}
app, err := webcmd.NewApp(*confPath)
if err != nil {
log.Fatalf(err.Error())