agent: use http.StatusMethodNotAllowed instead of 405

pull/3416/head
Frank Schroeder 2017-08-23 16:21:55 +02:00 committed by Frank Schröder
parent ad5c1d9e72
commit fa121be33f
6 changed files with 14 additions and 14 deletions

View File

@ -51,7 +51,7 @@ func (s *HTTPServer) ACLBootstrap(resp http.ResponseWriter, req *http.Request) (
func (s *HTTPServer) ACLDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) ACLDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Mandate a PUT request // Mandate a PUT request
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
@ -87,7 +87,7 @@ func (s *HTTPServer) ACLUpdate(resp http.ResponseWriter, req *http.Request) (int
func (s *HTTPServer) aclSet(resp http.ResponseWriter, req *http.Request, update bool) (interface{}, error) { func (s *HTTPServer) aclSet(resp http.ResponseWriter, req *http.Request, update bool) (interface{}, error) {
// Mandate a PUT request // Mandate a PUT request
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
@ -130,7 +130,7 @@ func (s *HTTPServer) aclSet(resp http.ResponseWriter, req *http.Request, update
func (s *HTTPServer) ACLClone(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) ACLClone(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Mandate a PUT request // Mandate a PUT request
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }

View File

@ -384,7 +384,7 @@ type checkUpdate struct {
// APIs. // APIs.
func (s *HTTPServer) AgentCheckUpdate(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) AgentCheckUpdate(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
@ -530,7 +530,7 @@ func (s *HTTPServer) AgentDeregisterService(resp http.ResponseWriter, req *http.
func (s *HTTPServer) AgentServiceMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) AgentServiceMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Only PUT supported // Only PUT supported
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
@ -586,7 +586,7 @@ func (s *HTTPServer) AgentServiceMaintenance(resp http.ResponseWriter, req *http
func (s *HTTPServer) AgentNodeMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) AgentNodeMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Only PUT supported // Only PUT supported
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
@ -629,7 +629,7 @@ func (s *HTTPServer) AgentNodeMaintenance(resp http.ResponseWriter, req *http.Re
func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Only GET supported. // Only GET supported.
if req.Method != "GET" { if req.Method != "GET" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }

View File

@ -22,7 +22,7 @@ const (
func (s *HTTPServer) EventFire(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) EventFire(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Mandate a PUT request // Mandate a PUT request
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }

View File

@ -48,7 +48,7 @@ func (s *HTTPServer) KVSEndpoint(resp http.ResponseWriter, req *http.Request) (i
case "DELETE": case "DELETE":
return s.KVSDelete(resp, req, &args) return s.KVSDelete(resp, req, &args)
default: default:
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
} }

View File

@ -71,7 +71,7 @@ func (s *HTTPServer) PreparedQueryGeneral(resp http.ResponseWriter, req *http.Re
return s.preparedQueryList(resp, req) return s.preparedQueryList(resp, req)
default: default:
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
} }
@ -261,7 +261,7 @@ func (s *HTTPServer) PreparedQuerySpecific(resp http.ResponseWriter, req *http.R
return s.preparedQueryDelete(id, resp, req) return s.preparedQueryDelete(id, resp, req)
default: default:
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
} }

View File

@ -29,7 +29,7 @@ type sessionCreateResponse struct {
func (s *HTTPServer) SessionCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) SessionCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Mandate a PUT request // Mandate a PUT request
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
@ -109,7 +109,7 @@ func FixupLockDelay(raw interface{}) error {
func (s *HTTPServer) SessionDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) SessionDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Mandate a PUT request // Mandate a PUT request
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }
@ -138,7 +138,7 @@ func (s *HTTPServer) SessionDestroy(resp http.ResponseWriter, req *http.Request)
func (s *HTTPServer) SessionRenew(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) SessionRenew(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// Mandate a PUT request // Mandate a PUT request
if req.Method != "PUT" { if req.Method != "PUT" {
resp.WriteHeader(405) resp.WriteHeader(http.StatusMethodNotAllowed) // 405
return nil, nil return nil, nil
} }