mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdhttp: add v2prefix
This commit is contained in:
parent
efe2141c16
commit
f1856abe60
@ -18,13 +18,13 @@ import (
|
|||||||
crand "crypto/rand"
|
crand "crypto/rand"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
|
||||||
"github.com/coreos/etcd/third_party/code.google.com/p/go.net/context"
|
|
||||||
"github.com/coreos/etcd/elog"
|
"github.com/coreos/etcd/elog"
|
||||||
etcderrors "github.com/coreos/etcd/error"
|
etcderrors "github.com/coreos/etcd/error"
|
||||||
"github.com/coreos/etcd/etcdserver"
|
"github.com/coreos/etcd/etcdserver"
|
||||||
"github.com/coreos/etcd/etcdserver/etcdserverpb"
|
"github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||||
"github.com/coreos/etcd/raft/raftpb"
|
"github.com/coreos/etcd/raft/raftpb"
|
||||||
"github.com/coreos/etcd/store"
|
"github.com/coreos/etcd/store"
|
||||||
|
"github.com/coreos/etcd/third_party/code.google.com/p/go.net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Peers map[int64][]string
|
type Peers map[int64][]string
|
||||||
@ -139,7 +139,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(r.URL.Path, "/raft"):
|
case strings.HasPrefix(r.URL.Path, "/raft"):
|
||||||
h.serveRaft(ctx, w, r)
|
h.serveRaft(ctx, w, r)
|
||||||
case strings.HasPrefix(r.URL.Path, "/keys/"):
|
case strings.HasPrefix(r.URL.Path, "/v2/keys/"):
|
||||||
h.serveKeys(ctx, w, r)
|
h.serveKeys(ctx, w, r)
|
||||||
default:
|
default:
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
@ -212,7 +212,7 @@ func parseRequest(r *http.Request) (etcdserverpb.Request, error) {
|
|||||||
Id: genId(),
|
Id: genId(),
|
||||||
Method: r.Method,
|
Method: r.Method,
|
||||||
Val: r.FormValue("value"),
|
Val: r.FormValue("value"),
|
||||||
Path: r.URL.Path[len("/keys"):],
|
Path: r.URL.Path[len("/v2/keys"):],
|
||||||
PrevValue: q.Get("prevValue"),
|
PrevValue: q.Get("prevValue"),
|
||||||
PrevIndex: parseUint64(q.Get("prevIndex")),
|
PrevIndex: parseUint64(q.Get("prevIndex")),
|
||||||
Recursive: parseBool(q.Get("recursive")),
|
Recursive: parseBool(q.Get("recursive")),
|
||||||
|
@ -45,7 +45,7 @@ func TestSet(t *testing.T) {
|
|||||||
s := httptest.NewServer(h)
|
s := httptest.NewServer(h)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
resp, err := http.PostForm(s.URL+"/keys/foo", url.Values{"value": {"bar"}})
|
resp, err := http.PostForm(s.URL+"/v2/keys/foo", url.Values{"value": {"bar"}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user