mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00

Conflicts: server/v2/tests/delete_handler_test.go server/v2/tests/get_handler_test.go server/v2/tests/post_handler_test.go server/v2/tests/put_handler_test.go third_party/github.com/coreos/go-etcd/etcd/requests.go
31 lines
674 B
Go
31 lines
674 B
Go
package v2
|
|
|
|
import (
|
|
"net/http"
|
|
"path"
|
|
"strconv"
|
|
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
// getIndexHandler retrieves the current lock index.
|
|
func (h *handler) getIndexHandler(w http.ResponseWriter, req *http.Request) {
|
|
h.client.SyncCluster()
|
|
|
|
vars := mux.Vars(req)
|
|
keypath := path.Join(prefix, vars["key"])
|
|
|
|
// Read all indices.
|
|
resp, err := h.client.Get(keypath, true, true)
|
|
if err != nil {
|
|
http.Error(w, "lock children lookup error: " + err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
// Write out the index of the last one to the response body.
|
|
indices := extractResponseIndices(resp)
|
|
if len(indices) > 0 {
|
|
w.Write([]byte(strconv.Itoa(indices[0])))
|
|
}
|
|
}
|