MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / FetchTask

Method FetchTask

relay/channel/task/suno/adaptor.go:133–159  ·  view source on GitHub ↗
(baseUrl, key string, body map[string]any)

Source from the content-addressed store, hash-verified

131}
132
133func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any) (*http.Response, error) {
134 requestUrl := fmt.Sprintf("%s/suno/fetch", baseUrl)
135 byteBody, err := json.Marshal(body)
136 if err != nil {
137 return nil, err
138 }
139
140 req, err := http.NewRequest("POST", requestUrl, bytes.NewBuffer(byteBody))
141 if err != nil {
142 common.SysError(fmt.Sprintf("Get Task error: %v", err))
143 return nil, err
144 }
145 defer req.Body.Close()
146 // 设置超时时间
147 timeout := time.Second * 15
148 ctx, cancel := context.WithTimeout(context.Background(), timeout)
149 defer cancel()
150 // 使用带有超时的 context 创建新的请求
151 req = req.WithContext(ctx)
152 req.Header.Set("Content-Type", "application/json")
153 req.Header.Set("Authorization", "Bearer "+key)
154 resp, err := service.GetHttpClient().Do(req)
155 if err != nil {
156 return nil, err
157 }
158 return resp, nil
159}
160
161func actionValidate(c *gin.Context, sunoRequest *dto.SunoSubmitReq, action string) (err error) {
162 switch action {

Callers

nothing calls this directly

Implementers 3

TaskAdaptorrelay/channel/task/jimeng/adaptor.go
TaskAdaptorrelay/channel/task/suno/adaptor.go
TaskAdaptorrelay/channel/task/kling/adaptor.go

Calls 1

GetHttpClientFunction · 0.92

Tested by

no test coverage detected