mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
use json.Marshal directly
This commit is contained in:
parent
7c7dfe3eeb
commit
a10a64856d
@ -84,8 +84,7 @@ func (s *KubeletServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
fmt.Fprint(w, "{}")
|
fmt.Fprint(w, "{}")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
encoder := json.NewEncoder(w)
|
data, err := json.Marshal(stats)
|
||||||
err = encoder.Encode(stats)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
fmt.Fprintf(w, "Internal Error: %#v", err)
|
fmt.Fprintf(w, "Internal Error: %#v", err)
|
||||||
@ -93,6 +92,7 @@ func (s *KubeletServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
w.Header().Add("Content-type", "application/json")
|
w.Header().Add("Content-type", "application/json")
|
||||||
|
w.Write(data)
|
||||||
case u.Path == "/containerInfo":
|
case u.Path == "/containerInfo":
|
||||||
container := u.Query().Get("container")
|
container := u.Query().Get("container")
|
||||||
if len(container) == 0 {
|
if len(container) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user