Update usages of http.ResponseWriter.WriteHeader to use http.Error
Signed-off-by: Ibrahim AshShohail <me@ibrasho.com>
This commit is contained in:
@@ -120,7 +120,7 @@ func makeTestServer(t *testing.T, namespace string) (*httptest.Server, *utiltest
|
||||
mux.Handle(testapi.Default.ResourcePath("endpoints/", namespace, ""), &fakeEndpointsHandler)
|
||||
mux.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
|
||||
t.Errorf("unexpected request: %v", req.RequestURI)
|
||||
res.WriteHeader(http.StatusNotFound)
|
||||
http.Error(res, "", http.StatusNotFound)
|
||||
})
|
||||
return httptest.NewServer(mux), &fakeEndpointsHandler
|
||||
}
|
||||
|
@@ -252,7 +252,7 @@ type debugHTTPHandler struct {
|
||||
|
||||
func (h *debugHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.Path != "/graph" {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
http.Error(w, "", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -270,8 +270,7 @@ func (h *debugHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
data, err := dot.Marshal(graph, "full", "", " ", false)
|
||||
if err != nil {
|
||||
w.Write([]byte(err.Error()))
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Write(data)
|
||||
|
Reference in New Issue
Block a user