|
|
|
@ -361,10 +361,10 @@ func (a *api) onConfigSet(ctx *gin.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
a.mutex.Lock() |
|
|
|
a.mutex.Lock() |
|
|
|
|
|
|
|
defer a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
var newConf conf.Conf |
|
|
|
var newConf conf.Conf |
|
|
|
cloneStruct(a.conf, &newConf) |
|
|
|
cloneStruct(a.conf, &newConf) |
|
|
|
a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fillStruct(&newConf, in) |
|
|
|
fillStruct(&newConf, in) |
|
|
|
|
|
|
|
|
|
|
|
err = newConf.CheckAndFillMissing() |
|
|
|
err = newConf.CheckAndFillMissing() |
|
|
|
@ -373,9 +373,7 @@ func (a *api) onConfigSet(ctx *gin.Context) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
a.mutex.Lock() |
|
|
|
|
|
|
|
a.conf = &newConf |
|
|
|
a.conf = &newConf |
|
|
|
a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// since reloading the configuration can cause the shutdown of the API,
|
|
|
|
// since reloading the configuration can cause the shutdown of the API,
|
|
|
|
// call it in a goroutine
|
|
|
|
// call it in a goroutine
|
|
|
|
@ -394,9 +392,10 @@ func (a *api) onConfigPathsAdd(ctx *gin.Context) { |
|
|
|
name := ctx.Param("name") |
|
|
|
name := ctx.Param("name") |
|
|
|
|
|
|
|
|
|
|
|
a.mutex.Lock() |
|
|
|
a.mutex.Lock() |
|
|
|
|
|
|
|
defer a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
var newConf conf.Conf |
|
|
|
var newConf conf.Conf |
|
|
|
cloneStruct(a.conf, &newConf) |
|
|
|
cloneStruct(a.conf, &newConf) |
|
|
|
a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _, ok := newConf.Paths[name]; ok { |
|
|
|
if _, ok := newConf.Paths[name]; ok { |
|
|
|
ctx.AbortWithStatus(http.StatusBadRequest) |
|
|
|
ctx.AbortWithStatus(http.StatusBadRequest) |
|
|
|
@ -413,9 +412,7 @@ func (a *api) onConfigPathsAdd(ctx *gin.Context) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
a.mutex.Lock() |
|
|
|
|
|
|
|
a.conf = &newConf |
|
|
|
a.conf = &newConf |
|
|
|
a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// since reloading the configuration can cause the shutdown of the API,
|
|
|
|
// since reloading the configuration can cause the shutdown of the API,
|
|
|
|
// call it in a goroutine
|
|
|
|
// call it in a goroutine
|
|
|
|
@ -434,9 +431,10 @@ func (a *api) onConfigPathsEdit(ctx *gin.Context) { |
|
|
|
name := ctx.Param("name") |
|
|
|
name := ctx.Param("name") |
|
|
|
|
|
|
|
|
|
|
|
a.mutex.Lock() |
|
|
|
a.mutex.Lock() |
|
|
|
|
|
|
|
defer a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
var newConf conf.Conf |
|
|
|
var newConf conf.Conf |
|
|
|
cloneStruct(a.conf, &newConf) |
|
|
|
cloneStruct(a.conf, &newConf) |
|
|
|
a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newConfPath, ok := newConf.Paths[name] |
|
|
|
newConfPath, ok := newConf.Paths[name] |
|
|
|
if !ok { |
|
|
|
if !ok { |
|
|
|
@ -452,9 +450,7 @@ func (a *api) onConfigPathsEdit(ctx *gin.Context) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
a.mutex.Lock() |
|
|
|
|
|
|
|
a.conf = &newConf |
|
|
|
a.conf = &newConf |
|
|
|
a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// since reloading the configuration can cause the shutdown of the API,
|
|
|
|
// since reloading the configuration can cause the shutdown of the API,
|
|
|
|
// call it in a goroutine
|
|
|
|
// call it in a goroutine
|
|
|
|
@ -467,9 +463,10 @@ func (a *api) onConfigPathsDelete(ctx *gin.Context) { |
|
|
|
name := ctx.Param("name") |
|
|
|
name := ctx.Param("name") |
|
|
|
|
|
|
|
|
|
|
|
a.mutex.Lock() |
|
|
|
a.mutex.Lock() |
|
|
|
|
|
|
|
defer a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
var newConf conf.Conf |
|
|
|
var newConf conf.Conf |
|
|
|
cloneStruct(a.conf, &newConf) |
|
|
|
cloneStruct(a.conf, &newConf) |
|
|
|
a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _, ok := newConf.Paths[name]; !ok { |
|
|
|
if _, ok := newConf.Paths[name]; !ok { |
|
|
|
ctx.AbortWithStatus(http.StatusBadRequest) |
|
|
|
ctx.AbortWithStatus(http.StatusBadRequest) |
|
|
|
@ -484,9 +481,7 @@ func (a *api) onConfigPathsDelete(ctx *gin.Context) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
a.mutex.Lock() |
|
|
|
|
|
|
|
a.conf = &newConf |
|
|
|
a.conf = &newConf |
|
|
|
a.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// since reloading the configuration can cause the shutdown of the API,
|
|
|
|
// since reloading the configuration can cause the shutdown of the API,
|
|
|
|
// call it in a goroutine
|
|
|
|
// call it in a goroutine
|
|
|
|
|