MCPcopy Create free account
hub / github.com/krau/SaveAny-Bot / GetTaskHandler

Method GetTaskHandler

api/handlers.go:80–100  ·  view source on GitHub ↗

GetTaskHandler 获取单个任务处理器

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

78
79// GetTaskHandler 获取单个任务处理器
80func (h *Handlers) GetTaskHandler(w http.ResponseWriter, r *http.Request) {
81 if r.Method != http.MethodGet {
82 WriteError(w, http.StatusMethodNotAllowed, "method_not_allowed", "only GET method is allowed")
83 return
84 }
85
86 taskID := extractTaskIDFromPath(r.URL.Path)
87 if taskID == "" {
88 WriteError(w, http.StatusBadRequest, "invalid_request", "task ID is required")
89 return
90 }
91
92 task, ok := GetTask(taskID)
93 if !ok {
94 WriteError(w, http.StatusNotFound, "task_not_found", "task not found: "+taskID)
95 return
96 }
97
98 resp := convertTaskProgressToResponse(task)
99 WriteJSON(w, http.StatusOK, resp)
100}
101
102// CancelTaskHandler 取消任务处理器
103func (h *Handlers) CancelTaskHandler(w http.ResponseWriter, r *http.Request) {

Callers 3

NewServerFunction · 0.95
TestGetTaskHandlerFunction · 0.80
TestEdgeCasesFunction · 0.80

Calls 5

WriteErrorFunction · 0.85
extractTaskIDFromPathFunction · 0.85
GetTaskFunction · 0.85
WriteJSONFunction · 0.85

Tested by 2

TestGetTaskHandlerFunction · 0.64
TestEdgeCasesFunction · 0.64