func handlePut()

in http.go [190:217]


func handlePut(ctx Context, w http.ResponseWriter, group *Group, key string, reqBody io.ReadCloser) {
	buf := new(bytes.Buffer)
	buf.ReadFrom(reqBody)
	var p putBody
	err := json.Unmarshal(buf.Bytes(), &p)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	var ttl *time.Time = nil
	if p.HasTTL {
		ttl = &p.TTL
	}
	err = group.Put(ctx, key, p.Value, ttl)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	// Write the value to the response body as a proto message.
	body, err := proto.Marshal(&pb.PutResponse{})
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	w.Header().Set("Content-Type", "application/x-protobuf")
	w.Write(body)
}