Пример #1
0
func getOutput(e *engine.Engine) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		uuid := mux.Vars(r)["uuid"]
		data := e.TaskOutput(uuid)

		w.Header().Set("Content-Type", "application/pdf")
		w.Write(data)
	}
}
Пример #2
0
func getAllJobs(e *engine.Engine) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		jobs := e.AllTasks()

		json, err := json.Marshal(wrapTasks(jobs))
		if err != nil {
			log.Fatal(err)
		}

		w.Write(json)
	}
}
Пример #3
0
func executeTemplate(e *engine.Engine, tc template.TemplateConfig) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		body, err := ioutil.ReadAll(r.Body)
		if err != nil {
			log.Fatal(err)
		}

		result := e.Submit(tc, body)

		http.Redirect(w, r, fmt.Sprintf("/task/%s", result.Uuid), 303)
		defer r.Body.Close()
	}
}
Пример #4
0
func getJob(e *engine.Engine) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		uuid := mux.Vars(r)["uuid"]
		job := e.Task(uuid)

		json, err := json.Marshal(newTaskInfo(job))
		if err != nil {
			log.Fatal(err)
		}

		w.Write(json)
	}
}