*: allows for BASE_PATH configuration (#183)

This commit is contained in:
Quentin Machu 2022-04-25 00:17:13 -07:00 committed by GitHub
parent 90bb2851bf
commit 87b08a8f7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 108 additions and 84 deletions

View file

@ -1,5 +1,7 @@
package util
import "strings"
// Runtime config
var (
DisableLogin bool
@ -17,6 +19,7 @@ var (
EmailContent string
SessionSecret []byte
WgConfTemplate string
BasePath string
)
const (
@ -32,3 +35,13 @@ const (
UsernameEnvVar = "WGUI_USERNAME"
PasswordEnvVar = "WGUI_PASSWORD"
)
func ParseBasePath(basePath string) string {
if !strings.HasPrefix(basePath, "/") {
basePath = "/" + basePath
}
if strings.HasSuffix(basePath, "/") {
basePath = strings.TrimSuffix(basePath, "/")
}
return basePath
}