// The ConfigHandler type provides handler functions for reading and manipulating
// the current config.
typeConfigHandlerstruct{
storeconfig.Store
}
// NewConfig return a new Config type. You have to provide a valid config store.
funcNewConfig(storeconfig.Store)*ConfigHandler{
return&ConfigHandler{
store:store,
}
}
// Get returns the currently active Restreamer configuration
// @Summary Retrieve the currently active Restreamer configuration
// @Description Retrieve the currently active Restreamer configuration
// @ID config-3-get
// @Produce json
// @Success 200 {object} api.Config
// @Security ApiKeyAuth
// @Router /api/v3/config [get]
func(p*ConfigHandler)Get(cecho.Context)error{
cfg:=p.store.GetActive()
apicfg:=api.Config{}
apicfg.Unmarshal(cfg)
returnc.JSON(http.StatusOK,apicfg)
}
// Set will set the given configuration as new active configuration
// @Summary Update the current Restreamer configuration
// @Description Update the current Restreamer configuration by providing a complete or partial configuration. Fields that are not provided will not be changed.
// @ID config-3-set
// @Accept json
// @Produce json
// @Param config body api.SetConfig true "Restreamer configuration"
// @Success 200 {string} string
// @Failure 400 {object} api.Error
// @Failure 409 {object} api.ConfigError
// @Security ApiKeyAuth
// @Router /api/v3/config [put]
func(p*ConfigHandler)Set(cecho.Context)error{
cfg:=p.store.Get()
// Set the current config as default config value. This will
// allow to set a partial config without destroying the other