From ad5c1d9e729adf6239c8cbaa3105125e2acd0619 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Wed, 23 Aug 2017 16:24:52 +0200 Subject: [PATCH] agent: use http.StatusNotFound instead of 404 --- agent/agent_endpoint.go | 4 ++-- agent/kvs_endpoint.go | 4 ++-- agent/prepared_query_endpoint.go | 6 +++--- agent/session_endpoint.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/agent/agent_endpoint.go b/agent/agent_endpoint.go index d3c726c830..37bf8a91ca 100644 --- a/agent/agent_endpoint.go +++ b/agent/agent_endpoint.go @@ -568,13 +568,13 @@ func (s *HTTPServer) AgentServiceMaintenance(resp http.ResponseWriter, req *http if enable { reason := params.Get("reason") if err = s.agent.EnableServiceMaintenance(serviceID, reason, token); err != nil { - resp.WriteHeader(404) + resp.WriteHeader(http.StatusNotFound) // 404 fmt.Fprint(resp, err.Error()) return nil, nil } } else { if err = s.agent.DisableServiceMaintenance(serviceID); err != nil { - resp.WriteHeader(404) + resp.WriteHeader(http.StatusNotFound) // 404 fmt.Fprint(resp, err.Error()) return nil, nil } diff --git a/agent/kvs_endpoint.go b/agent/kvs_endpoint.go index d6e2fd08b8..86f2f9766b 100644 --- a/agent/kvs_endpoint.go +++ b/agent/kvs_endpoint.go @@ -73,7 +73,7 @@ func (s *HTTPServer) KVSGet(resp http.ResponseWriter, req *http.Request, args *s // Check if we get a not found if len(out.Entries) == 0 { - resp.WriteHeader(404) + resp.WriteHeader(http.StatusNotFound) // 404 return nil, nil } @@ -120,7 +120,7 @@ func (s *HTTPServer) KVSGetKeys(resp http.ResponseWriter, req *http.Request, arg // Check if we get a not found. We do not generate // not found for the root, but just provide the empty list if len(out.Keys) == 0 && listArgs.Prefix != "" { - resp.WriteHeader(404) + resp.WriteHeader(http.StatusNotFound) // 404 return nil, nil } diff --git a/agent/prepared_query_endpoint.go b/agent/prepared_query_endpoint.go index e72a7c6d3e..1f4f6976c4 100644 --- a/agent/prepared_query_endpoint.go +++ b/agent/prepared_query_endpoint.go @@ -111,7 +111,7 @@ func (s *HTTPServer) preparedQueryExecute(id string, resp http.ResponseWriter, r // We have to check the string since the RPC sheds // the specific error type. if err.Error() == consul.ErrQueryNotFound.Error() { - resp.WriteHeader(404) + resp.WriteHeader(http.StatusNotFound) // 404 fmt.Fprint(resp, err.Error()) return nil, nil } @@ -155,7 +155,7 @@ func (s *HTTPServer) preparedQueryExplain(id string, resp http.ResponseWriter, r // We have to check the string since the RPC sheds // the specific error type. if err.Error() == consul.ErrQueryNotFound.Error() { - resp.WriteHeader(404) + resp.WriteHeader(http.StatusNotFound) // 404 fmt.Fprint(resp, err.Error()) return nil, nil } @@ -178,7 +178,7 @@ func (s *HTTPServer) preparedQueryGet(id string, resp http.ResponseWriter, req * // We have to check the string since the RPC sheds // the specific error type. if err.Error() == consul.ErrQueryNotFound.Error() { - resp.WriteHeader(404) + resp.WriteHeader(http.StatusNotFound) // 404 fmt.Fprint(resp, err.Error()) return nil, nil } diff --git a/agent/session_endpoint.go b/agent/session_endpoint.go index bd99763f5a..ae453e06cc 100644 --- a/agent/session_endpoint.go +++ b/agent/session_endpoint.go @@ -159,7 +159,7 @@ func (s *HTTPServer) SessionRenew(resp http.ResponseWriter, req *http.Request) ( if err := s.agent.RPC("Session.Renew", &args, &out); err != nil { return nil, err } else if out.Sessions == nil { - resp.WriteHeader(404) + resp.WriteHeader(http.StatusNotFound) // 404 fmt.Fprintf(resp, "Session id '%s' not found", args.Session) return nil, nil }