mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
feat(server): add HEAD for v1/watch
This commit is contained in:
parent
89d3df242c
commit
76ac1da7ea
@ -103,7 +103,7 @@ func (s *Server) installV1(r *mux.Router) {
|
||||
s.handleFuncV1(r, "/v1/keys/{key:.*}", v1.GetKeyHandler).Methods("GET", "HEAD")
|
||||
s.handleFuncV1(r, "/v1/keys/{key:.*}", v1.SetKeyHandler).Methods("POST", "PUT")
|
||||
s.handleFuncV1(r, "/v1/keys/{key:.*}", v1.DeleteKeyHandler).Methods("DELETE")
|
||||
s.handleFuncV1(r, "/v1/watch/{key:.*}", v1.WatchKeyHandler).Methods("GET", "POST")
|
||||
s.handleFuncV1(r, "/v1/watch/{key:.*}", v1.WatchKeyHandler).Methods("GET", "HEAD", "POST")
|
||||
s.handleFunc(r, "/v1/leader", s.GetLeaderHandler).Methods("GET", "HEAD")
|
||||
s.handleFunc(r, "/v1/machines", s.GetPeersHandler).Methods("GET", "HEAD")
|
||||
s.handleFunc(r, "/v1/peers", s.GetPeersHandler).Methods("GET", "HEAD")
|
||||
|
@ -32,9 +32,11 @@ func WatchKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
event := <-watcher.EventChan
|
||||
|
||||
// Convert event to a response and write to client.
|
||||
b, _ := json.Marshal(event.Response(s.Store().Index()))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if req.Method == "HEAD" {
|
||||
return nil
|
||||
}
|
||||
b, _ := json.Marshal(event.Response(s.Store().Index()))
|
||||
w.Write(b)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user