From b6378dae511dd21263e629ca9559b10ccb9e59b8 Mon Sep 17 00:00:00 2001 From: "Fabrizio (Misto) Milo" Date: Tue, 6 Aug 2013 16:47:57 -0700 Subject: [PATCH] use go's syntax --- client_handlers.go | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/client_handlers.go b/client_handlers.go index 6936022b0..025344bfd 100644 --- a/client_handlers.go +++ b/client_handlers.go @@ -70,18 +70,22 @@ func SetHttpHandler(w *http.ResponseWriter, req *http.Request) { } if len(prevValue) != 0 { - command := &TestAndSetCommand{} - command.Key = key - command.Value = value - command.PrevValue = prevValue - command.ExpireTime = expireTime + command := &TestAndSetCommand{ + Key: key, + Value: value, + PrevValue: prevValue, + ExpireTime: expireTime, + } + dispatch(command, w, req, true) } else { - command := &SetCommand{} - command.Key = key - command.Value = value - command.ExpireTime = expireTime + command := &SetCommand{ + Key: key, + Value: value, + ExpireTime: expireTime, + } + dispatch(command, w, req, true) } @@ -93,8 +97,9 @@ func DeleteHttpHandler(w *http.ResponseWriter, req *http.Request) { debugf("[recv] DELETE http://%v/v1/keys/%s", raftServer.Name(), key) - command := &DeleteCommand{} - command.Key = key + command := &DeleteCommand{ + Key: key, + } dispatch(command, w, req, true) } @@ -244,8 +249,9 @@ func GetHttpHandler(w *http.ResponseWriter, req *http.Request) { debugf("[recv] GET http://%v/v1/keys/%s", raftServer.Name(), key) - command := &GetCommand{} - command.Key = key + command := &GetCommand{ + Key: key, + } if body, err := command.Apply(raftServer); err != nil { @@ -275,8 +281,9 @@ func GetHttpHandler(w *http.ResponseWriter, req *http.Request) { func WatchHttpHandler(w http.ResponseWriter, req *http.Request) { key := req.URL.Path[len("/v1/watch/"):] - command := &WatchCommand{} - command.Key = key + command := &WatchCommand{ + Key: key, + } if req.Method == "GET" { debugf("[recv] GET http://%v/watch/%s", raftServer.Name(), key)