// DeQHTTPHandler provides the HTTP endpoint for dequeuing tasks. type DeQHTTPHandler httpHandler func (h *DeQHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { q, ok := mux.Vars(r)["queue"] if !ok { http.Error(w, "unkown queue", http.StatusBadRequest) return } ctx, cnl := context.WithTimeout(context.Background(), httpTimeout) defer cnl() d := Deque{ Queue: Queue(q), } v, err := h.Hive.Sync(ctx, d) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } if err = json.NewEncoder(w).Encode(v.(Task)); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } }