Ejemplo n.º 1
0
Archivo: list.go Proyecto: utako/atc
func (s *Server) ListWorkers(w http.ResponseWriter, r *http.Request) {
	workerInfos, err := s.db.Workers()
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	workers := make([]atc.Worker, len(workerInfos))
	for i := 0; i < len(workerInfos); i++ {
		workers[i] = present.Worker(workerInfos[i])
	}

	json.NewEncoder(w).Encode(workers)
}
Ejemplo n.º 2
0
func (s *Server) ListWorkers(w http.ResponseWriter, r *http.Request) {
	logger := s.logger.Session("list-workers")
	savedWorkers, err := s.db.Workers()
	if err != nil {
		logger.Error("failed-to-get-workers", err)
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	workers := make([]atc.Worker, len(savedWorkers))
	for i, savedWorker := range savedWorkers {
		workers[i] = present.Worker(savedWorker.WorkerInfo)
	}

	json.NewEncoder(w).Encode(workers)
}