webcmd: external versioning
This commit is contained in:
parent
048bf09c94
commit
a36a293dfa
4
App.go
4
App.go
@ -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 == "/" {
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user