// Put writes a zone config for the specified key prefix "key". The // zone config is parsed from the input "body". The zone config is // stored gob-encoded. The specified body must be valid utf8 and must // validly parse into a zone config struct. func (zh *zoneHandler) Put(path string, body []byte, r *http.Request) error { if len(path) == 0 { return util.Errorf("no path specified for zone Put") } configStr := string(body) if !utf8.ValidString(configStr) { return util.Errorf("config contents not valid utf8: %q", body) } config, err := storage.ParseZoneConfig(body) if err != nil { return util.Errorf("zone config has invalid format: %s: %v", configStr, err) } zoneKey := engine.MakeKey(engine.KeyConfigZonePrefix, engine.Key(path[1:])) if err := kv.PutI(zh.kvDB, zoneKey, config, hlc.HLTimestamp{}); err != nil { return err } return nil }
// Put writes a zone config for the specified key prefix "key". The // zone config is parsed from the input "body". The zone config is // stored as YAML text. The specified body must be valid utf8 and // must validly parse into a zone config struct. func (zh *zoneHandler) Put(path string, body []byte, r *http.Request) error { if len(path) == 0 { return util.Errorf("no path specified for zone Put") } configStr := string(body) if !utf8.ValidString(configStr) { return util.Errorf("config contents not valid utf8: %q", body) } _, err := storage.ParseZoneConfig(body) if err != nil { return util.Errorf("zone config has invalid format: %s: %v", configStr, err) } zoneKey := storage.MakeKey(storage.KeyConfigZonePrefix, storage.Key(path[1:])) pr := <-zh.kvDB.Put(&storage.PutRequest{Key: zoneKey, Value: storage.Value{Bytes: body}}) if pr.Error != nil { return pr.Error } return nil }