When changing configuration in parallel by editing the configuration file and calling the API, the server could get into a deadlock that prevented any further action. This is fixed.
34 lines
705 B
Go
34 lines
705 B
Go
package api //nolint:revive
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/bluenviron/mediamtx/internal/conf"
|
|
"github.com/bluenviron/mediamtx/internal/conf/jsonwrapper"
|
|
)
|
|
|
|
func (a *API) onConfigGlobalGet(ctx *gin.Context) {
|
|
c := a.Parent.APIConfigSnapshot()
|
|
|
|
ctx.JSON(http.StatusOK, c.Global())
|
|
}
|
|
|
|
func (a *API) onConfigGlobalPatch(ctx *gin.Context) {
|
|
var c conf.OptionalGlobal
|
|
err := jsonwrapper.Decode(&customLimitReader{ctx.Request.Body, maxInboundConfigSize}, &c)
|
|
if err != nil {
|
|
a.writeError(ctx, http.StatusBadRequest, err)
|
|
return
|
|
}
|
|
|
|
err = a.Parent.APIConfigGlobalPatch(c)
|
|
if err != nil {
|
|
a.writeError(ctx, http.StatusBadRequest, err)
|
|
return
|
|
}
|
|
|
|
a.writeOK(ctx)
|
|
}
|