Beispiel #1
0
func JobsDelete(rw http.ResponseWriter, r *http.Request) error {
	app := mux.Vars(r)["app"]
	job, err := strconv.Atoi(mux.Vars(r)["job"])

	if err != nil {
		return err
	}

	err = models.DeleteJob(app, job)

	if err != nil {
		return err
	}

	return RenderSuccess(rw)
}
Beispiel #2
0
func JobsCreate(rw http.ResponseWriter, r *http.Request) error {
	app := mux.Vars(r)["app"]

	body, err := ioutil.ReadAll(r.Body)

	if err != nil {
		return err
	}

	var job models.Job
	err = json.Unmarshal(body, &job)

	if err != nil {
		return err
	}

	if app != job.App {
		return fmt.Errorf("app name does not match")
	}

	err = models.CreateJob(&job)

	if err != nil {
		return err
	}

	return RenderJson(rw, job)
}
Beispiel #3
0
func JobsList(rw http.ResponseWriter, r *http.Request) error {
	app := mux.Vars(r)["app"]

	jobs, err := models.ListJobs(app)

	if err != nil {
		return err
	}

	return RenderJson(rw, jobs)
}