Beispiel #1
0
// change the current config to a spesific version
func (c *ConfigVersion) Post(req *Request) {

	var p config.Provider
	c.pipeline.ViewConfig(func(conf *config.AppConfig) {
		p = conf.Provider()
	})

	vars := mux.Vars(req.r)
	version, ok := vars["version"]
	if !ok {
		http.Error(req.w, "must append config version", http.StatusBadRequest)
		return
	}

	// get the config that this version is looking for
	conf, err := p.GetConfig(version)
	if err != nil {
		logrus.Error(err)
		http.Error(req.w, err.Error(), http.StatusBadRequest)
		return
	}

	_, err = p.PutConfig(conf, req.u)
	if err != nil {
		logrus.Error(err)
		http.Error(req.w, err.Error(), http.StatusBadRequest)
		return
	}

	c.pipeline.Refresh(conf)

}