github.com/ghodss/etcd@v0.3.1-0.20140417172404-cc329bfa55cb/mod/leader/v2/get_handler.go (about) 1 package v2 2 3 import ( 4 "fmt" 5 "io" 6 "net/http" 7 8 "github.com/coreos/etcd/third_party/github.com/gorilla/mux" 9 ) 10 11 // getHandler retrieves the current leader. 12 func (h *handler) getHandler(w http.ResponseWriter, req *http.Request) error { 13 vars := mux.Vars(req) 14 15 // Proxy the request to the lock service. 16 url := fmt.Sprintf("%s/mod/v2/lock/%s?field=value", h.addr, vars["key"]) 17 resp, err := h.client.Get(url) 18 if err != nil { 19 return err 20 } 21 defer resp.Body.Close() 22 23 w.WriteHeader(resp.StatusCode) 24 io.Copy(w, resp.Body) 25 return nil 26 }