fix(be): check port format

This commit is contained in:
Denis Gukov 2023-09-20 10:22:26 +02:00
parent bc3210994a
commit 67099f1031

View File

@ -15,6 +15,7 @@ import (
"github.com/spf13/cobra"
"net/http"
"os"
"strings"
)
var configPath string
@ -48,6 +49,12 @@ func runService() {
util.Config.PrintDbInfo()
port := util.Config.Port
if !strings.HasPrefix(port, ":") {
port = ":" + port
}
fmt.Printf("Tmp Path (projects home) %v\n", util.Config.TmpPath)
fmt.Printf("Semaphore %v\n", util.Version)
fmt.Printf("Interface %v\n", util.Config.Interface)
@ -81,7 +88,7 @@ func runService() {
store.Close("root")
}
err := http.ListenAndServe(util.Config.Interface+util.Config.Port, cropTrailingSlashMiddleware(router))
err := http.ListenAndServe(util.Config.Interface+port, cropTrailingSlashMiddleware(router))
if err != nil {
log.Panic(err)