mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 18:00:05 +00:00
rewrite basepath
This commit is contained in:
16
src/main.go
16
src/main.go
@@ -21,11 +21,11 @@ func main() {
|
||||
log.SetOutput(os.Stdout)
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
||||
|
||||
var addr, db, authfile, certfile, keyfile string
|
||||
var addr, db, authfile, certfile, keyfile, basepath string
|
||||
var ver, open bool
|
||||
flag.StringVar(&addr, "addr", "127.0.0.1:7070", "address to run server on")
|
||||
flag.StringVar(&authfile, "auth-file", "", "path to a file containing username:password")
|
||||
flag.StringVar(&server.BasePath, "base", "", "base path of the service url")
|
||||
flag.StringVar(&basepath, "base", "", "base path of the service url")
|
||||
flag.StringVar(&certfile, "cert-file", "", "path to cert file for https")
|
||||
flag.StringVar(&keyfile, "key-file", "", "path to key file for https")
|
||||
flag.StringVar(&db, "db", "", "storage file path")
|
||||
@@ -38,14 +38,6 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if server.BasePath != "" && !strings.HasPrefix(server.BasePath, "/") {
|
||||
server.BasePath = "/" + server.BasePath
|
||||
}
|
||||
|
||||
if server.BasePath != "" && strings.HasSuffix(server.BasePath, "/") {
|
||||
server.BasePath = strings.TrimSuffix(server.BasePath, "/")
|
||||
}
|
||||
|
||||
configPath, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
log.Fatal("Failed to get config dir: ", err)
|
||||
@@ -92,6 +84,10 @@ func main() {
|
||||
|
||||
srv := server.NewServer(store, addr)
|
||||
|
||||
if basepath != "" {
|
||||
srv.BasePath = "/" + strings.Trim(basepath, "/")
|
||||
}
|
||||
|
||||
if certfile != "" && keyfile != "" {
|
||||
srv.CertFile = certfile
|
||||
srv.KeyFile = keyfile
|
||||
|
Reference in New Issue
Block a user