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

Function DoWorkerRequest

service/cf_worker.go:23–43  ·  view source on GitHub ↗

DoWorkerRequest 通过Worker发送请求

(req *WorkerRequest)

Source from the content-addressed store, hash-verified

21
22// DoWorkerRequest 通过Worker发送请求
23func DoWorkerRequest(req *WorkerRequest) (*http.Response, error) {
24 if !setting.EnableWorker() {
25 return nil, fmt.Errorf("worker not enabled")
26 }
27 if !setting.WorkerAllowHttpImageRequestEnabled && !strings.HasPrefix(req.URL, "https") {
28 return nil, fmt.Errorf("only support https url")
29 }
30
31 workerUrl := setting.WorkerUrl
32 if !strings.HasSuffix(workerUrl, "/") {
33 workerUrl += "/"
34 }
35
36 // 序列化worker请求数据
37 workerPayload, err := json.Marshal(req)
38 if err != nil {
39 return nil, fmt.Errorf("failed to marshal worker payload: %v", err)
40 }
41
42 return http.Post(workerUrl, "application/json", bytes.NewBuffer(workerPayload))
43}
44
45func DoDownloadRequest(originUrl string) (resp *http.Response, err error) {
46 if setting.EnableWorker() {

Callers 2

DoDownloadRequestFunction · 0.85
SendWebhookNotifyFunction · 0.85

Calls 1

EnableWorkerFunction · 0.92

Tested by

no test coverage detected