Files
nomad/command/agent/resources_endpoint.go
James Nugent fda3868577 build: Apply goimports formatting to various files
The following files were not formatted as the output of goimports(1)
would create, causing the goimports linter to fail:

command/agent/resources_endpoint.go
nomad/resources_endpoint.go
nomad/resources_endpoint_test.go
2017-08-14 11:51:47 +08:00

33 lines
862 B
Go

package agent
import (
"net/http"
"github.com/hashicorp/nomad/nomad/structs"
)
// ResourceListRequest accepts a prefix and context and returns a list of matching
// IDs for that context.
func (s *HTTPServer) ResourceListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
if req.Method == "POST" || req.Method == "PUT" {
return s.resourcesRequest(resp, req)
}
return nil, CodedError(405, ErrInvalidMethod)
}
func (s *HTTPServer) resourcesRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
args := structs.ResourceListRequest{}
if err := decodeBody(req, &args); err != nil {
return nil, CodedError(400, err.Error())
}
var out structs.ResourceListResponse
if err := s.agent.RPC("Resources.List", &args, &out); err != nil {
return nil, err
}
setMeta(resp, &out.QueryMeta)
return out, nil
}