*: move v2http handlers without /v2 prefix to etcdhttp

Lets --enable-v2=false configurations provide /metrics, /health, etc.

Fixes #8167
This commit is contained in:
Anthony Romano
2017-05-09 19:39:29 -07:00
committed by Gyu-Ho Lee
parent ff9a0a3527
commit 8ab42fb045
10 changed files with 308 additions and 192 deletions

View File

@ -154,9 +154,10 @@ func (e Error) StatusCode() int {
return status
}
func (e Error) WriteTo(w http.ResponseWriter) {
func (e Error) WriteTo(w http.ResponseWriter) error {
w.Header().Add("X-Etcd-Index", fmt.Sprint(e.Index))
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(e.StatusCode())
fmt.Fprintln(w, e.toJsonString())
_, err := w.Write([]byte(e.toJsonString() + "\n"))
return err
}