func writeKeyEvent(w http.ResponseWriter, resp etcdserver.Response, noValueOnSuccess bool) error {
	ev := resp.Event
	if ev == nil {
		return errors.New("cannot write empty Event")
	}
	w.Header().Set("Content-Type", "application/json")
	w.Header().Set("X-Etcd-Index", fmt.Sprint(ev.EtcdIndex))
	w.Header().Set("X-Raft-Index", fmt.Sprint(resp.Index))
	w.Header().Set("X-Raft-Term", fmt.Sprint(resp.Term))

	if ev.IsCreated() {
		w.WriteHeader(http.StatusCreated)
	}

	ev = trimEventPrefix(ev, etcdserver.StoreKeysPrefix)
	if noValueOnSuccess &&
		(ev.Action == v2store.Set || ev.Action == v2store.CompareAndSwap ||
			ev.Action == v2store.Create || ev.Action == v2store.Update) {
		ev.Node = nil
		ev.PrevNode = nil
	}
	return json.NewEncoder(w).Encode(ev)
}
func writeKeyEvent(w http.ResponseWriter, resp etcdserver.Response, noValueOnSuccess bool) error {
	ev := resp.Event
	if ev == nil {
		return errors.New("cannot write empty Event")
	}
	w.Header().Set("Content-Type", "application/json")
	w.Header().Set("X-Etcd-Index", fmt.Sprint(ev.EtcdIndex))
	w.Header().Set("X-Raft-Index", fmt.Sprint(resp.Index))
	w.Header().Set("X-Raft-Term", fmt.Sprint(resp.Term))

	if ev.IsCreated() {
		w.WriteHeader(http.StatusCreated)
	}

	ev = trimEventPrefix(ev, etcdserver.StoreKeysPrefix)
	if noValueOnSuccess &&
		(ev.Action == v2store.Set || ev.Action == v2store.CompareAndSwap ||
			ev.Action == v2store.Create || ev.Action == v2store.Update) {
		ev.Node = nil
		ev.PrevNode = nil
	}
	return json.NewEncoder(w).Encode(ev)
}
func writeKeyEvent ( w http . ResponseWriter , resp etcdserver . Response , noValueOnSuccess bool ) error { ev := resp . Event if ev == nil { return errors . New ( " " ) } w . Header ( ) . Set ( " " , " " ) w . Header ( ) . Set ( " " , fmt . Sprint ( ev . EtcdIndex ) ) w . Header ( ) . Set ( " " , fmt . Sprint ( resp . Index ) ) w . Header ( ) . Set ( " " , fmt . Sprint ( resp . Term ) ) if ev . IsCreated ( ) { w . WriteHeader ( http . StatusCreated ) } ev = trimEventPrefix ( ev , etcdserver . StoreKeysPrefix ) if noValueOnSuccess && ( ev . Action == v2store . Set || ev . Action == v2store . CompareAndSwap || ev . Action == v2store . Create || ev . Action == v2store . Update ) { ev . Node = nil ev . PrevNode = nil } return json . NewEncoder ( w ) . Encode ( ev ) }
// writeKeyEvent trims the prefix of key path in a single Event under
// StoreKeysPrefix, serializes it and writes the resulting JSON to the given
// ResponseWriter, along with the appropriate headers.
writeKeyEvent trims the prefix of key path in a single Event under StoreKeysPrefix serializes it and writes the resulting JSON to the given ResponseWriter along with the appropriate headers .