/* Test with this curl command: */ func TaskCreate(w http.ResponseWriter, r *http.Request) { var v orchestrator.Graph body, err := ioutil.ReadAll(io.LimitReader(r.Body, 1048576)) if err != nil { panic(err) } if err := r.Body.Close(); err != nil { panic(err) } if err := json.Unmarshal(body, &v); err != nil { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusBadRequest) // unprocessable entity if err := json.NewEncoder(w).Encode(err); err != nil { panic(err) } return } uuid := uuid() exe := orchestrator.ExecutorBackend{ Name: "self", Url: "https://127.0.0.1:8585/v1", Certificate: "orchestrator.pem", Key: "orchestrator_key.pem", CACert: "executor.pem", Ping: "/ping", Client: nil, } exe.Init() go v.Run([]orchestrator.ExecutorBackend{exe}) v.Timeout = time.After(5 * time.Minute) tasks[uuid.ID] = &v w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusAccepted) if err := json.NewEncoder(w).Encode(uuid); err != nil { panic(err) } return }