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) } }
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) } }
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() } }
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) } }