Skip to content

Commit

Permalink
agent: align /agent/check/{fail,warn,pass} with reality
Browse files Browse the repository at this point in the history
/agent/check/{fail,warn,pass} uses PUT instead of GET as documented.
  • Loading branch information
magiconair committed Aug 19, 2017
1 parent a90783f commit 97a6a30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
15 changes: 6 additions & 9 deletions agent/agent_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,8 @@ func (s *HTTPServer) AgentDeregisterCheck(resp http.ResponseWriter, req *http.Re
}

func (s *HTTPServer) AgentCheckPass(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// todo(fs): why GET?
if req.Method != "GET" {
return nil, MethodNotAllowedError{req.Method, []string{"GET"}}
if req.Method != "PUT" {
return nil, MethodNotAllowedError{req.Method, []string{"PUT"}}
}

checkID := types.CheckID(strings.TrimPrefix(req.URL.Path, "/v1/agent/check/pass/"))
Expand All @@ -370,9 +369,8 @@ func (s *HTTPServer) AgentCheckPass(resp http.ResponseWriter, req *http.Request)
}

func (s *HTTPServer) AgentCheckWarn(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// todo(fs): why GET?
if req.Method != "GET" {
return nil, MethodNotAllowedError{req.Method, []string{"GET"}}
if req.Method != "PUT" {
return nil, MethodNotAllowedError{req.Method, []string{"PUT"}}
}

checkID := types.CheckID(strings.TrimPrefix(req.URL.Path, "/v1/agent/check/warn/"))
Expand All @@ -393,9 +391,8 @@ func (s *HTTPServer) AgentCheckWarn(resp http.ResponseWriter, req *http.Request)
}

func (s *HTTPServer) AgentCheckFail(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
// todo(fs): why GET?
if req.Method != "GET" {
return nil, MethodNotAllowedError{req.Method, []string{"GET"}}
if req.Method != "PUT" {
return nil, MethodNotAllowedError{req.Method, []string{"PUT"}}
}

checkID := types.CheckID(strings.TrimPrefix(req.URL.Path, "/v1/agent/check/fail/"))
Expand Down
6 changes: 3 additions & 3 deletions agent/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ func TestHTTPAPI_MethodNotAllowed(t *testing.T) {
{"GET", "/v1/agent/self"},
{"GET", "/v1/agent/members"},
{"PUT", "/v1/agent/check/deregister/"},
{"GET", "/v1/agent/check/fail/"}, // GET ??
{"GET", "/v1/agent/check/pass/"}, // GET ??
{"PUT", "/v1/agent/check/fail/"},
{"PUT", "/v1/agent/check/pass/"},
{"PUT", "/v1/agent/check/register"},
{"PUT", "/v1/agent/check/update/"},
{"GET", "/v1/agent/check/warn/"}, // GET ??
{"PUT", "/v1/agent/check/warn/"},
{"GET", "/v1/agent/checks"},
{"PUT", "/v1/agent/force-leave/"},
{"PUT", "/v1/agent/join/"},
Expand Down
6 changes: 3 additions & 3 deletions website/source/api/agent/check.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ This endpoint is used with a TTL type check to set the status of the check to

| Method | Path | Produces |
| ------ | ----------------------------- | -------------------------- |
| `GET` | `/agent/check/pass/:check_id` | `application/json` |
| `PUT` | `/agent/check/pass/:check_id` | `application/json` |

The table below shows this endpoint's support for
[blocking queries](/api/index.html#blocking-queries),
Expand Down Expand Up @@ -247,7 +247,7 @@ This endpoint is used with a TTL type check to set the status of the check to

| Method | Path | Produces |
| ------ | ----------------------------- | -------------------------- |
| `GET` | `/agent/check/warn/:check_id` | `application/json` |
| `PUT` | `/agent/check/warn/:check_id` | `application/json` |

The table below shows this endpoint's support for
[blocking queries](/api/index.html#blocking-queries),
Expand Down Expand Up @@ -280,7 +280,7 @@ This endpoint is used with a TTL type check to set the status of the check to

| Method | Path | Produces |
| ------ | ----------------------------- | -------------------------- |
| `GET` | `/agent/check/fail/:check_id` | `application/json` |
| `PUT` | `/agent/check/fail/:check_id` | `application/json` |

The table below shows this endpoint's support for
[blocking queries](/api/index.html#blocking-queries),
Expand Down

0 comments on commit 97a6a30

Please sign in to comment.