mirror of https://github.com/hashicorp/consul
agent: use http.StatusNotFound instead of 404
parent
1a557ee9e9
commit
ad5c1d9e72
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue