webcmd: external versioning
This commit is contained in:
parent
048bf09c94
commit
a36a293dfa
4
App.go
4
App.go
@ -10,6 +10,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var APP_VERSION string = "x.x.x" // Overridden by makefile
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
cfg AppConfig
|
cfg AppConfig
|
||||||
|
|
||||||
@ -44,7 +46,7 @@ func NewAppFromConfig(cfg AppConfig) *App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
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.Method == "GET" {
|
||||||
if r.URL.Path == "/" {
|
if r.URL.Path == "/" {
|
||||||
|
@ -2,15 +2,23 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"code.ivysaur.me/webcmd"
|
"code.ivysaur.me/webcmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
confPath := flag.String("config", "webcmd.conf", "Path to configuration file")
|
confPath := flag.String("config", "webcmd.conf", "Path to configuration file")
|
||||||
|
versionFlag := flag.Bool("version", false, "Display version number and exit")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *versionFlag {
|
||||||
|
fmt.Println("webcmd/" + webcmd.APP_VERSION)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
app, err := webcmd.NewApp(*confPath)
|
app, err := webcmd.NewApp(*confPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf(err.Error())
|
log.Fatalf(err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user