func handleWorkers(workerManager *client.WorkerManager, w http.ResponseWriter, r *http.Request) { workerStates := workerManager.ListWorkers() w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(workerStates); err != nil { panic(err) } }
func handleRegisterWorker(workerManager *client.WorkerManager, w http.ResponseWriter, r *http.Request) { info := client.WorkerInfo{ Id: r.FormValue("id"), Article: bitwrk.ArticleId(r.FormValue("article")), Method: "http-push", PushURL: r.FormValue("pushurl"), } if r.Method != "POST" || info.Id == "" || info.PushURL == "" { registerWorkerTemplate.Execute(w, info) } workerManager.RegisterWorker(info) }
func handleUnregisterWorker(workerManager *client.WorkerManager, w http.ResponseWriter, r *http.Request) { workerManager.UnregisterWorker(r.FormValue("id")) }