open-nomad/command/agent/region_endpoint.go

25 lines
518 B
Go
Raw Normal View History

2015-11-24 05:47:11 +00:00
package agent
import (
"net/http"
"github.com/hashicorp/nomad/nomad/structs"
)
2015-11-24 06:22:48 +00:00
func (s *HTTPServer) RegionListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
2015-11-24 05:47:11 +00:00
if req.Method != "GET" {
return nil, CodedError(405, ErrInvalidMethod)
}
var args structs.GenericRequest
if s.parse(resp, req, &args.Region, &args.QueryOptions) {
return nil, nil
}
var regions []string
if err := s.agent.RPC("Region.List", &args, &regions); err != nil {
return nil, err
}
return regions, nil
}