Beispiel #1
0
// Delete remove the given Job ID
func (h *Jobs) Delete(w http.ResponseWriter, r *http.Request) {
	id := mux.Vars(r)["id"]
	_, err := h.repository.Cancel(id)
	if err != nil {
		ErrorResponse(w, err, http.StatusInternalServerError)
	}
}
Beispiel #2
0
// Find retrieves the job specified by the 'id' path parameter
func (h *Jobs) Find(w http.ResponseWriter, r *http.Request) {
	id := mux.Vars(r)["id"]
	job, err := h.repository.Get(id)

	if err != nil {
		ErrorResponse(w, err, http.StatusInternalServerError)
		return
	}

	if job.ID == "" {
		w.WriteHeader(http.StatusNotFound)
		return
	}

	var resBuf = new(bytes.Buffer)
	encErr := json.NewEncoder(resBuf).Encode(job)
	if encErr != nil {
		ErrorResponse(w, encErr, http.StatusInternalServerError)
		return
	}
	w.Write(resBuf.Bytes())
}