chromeworker/proxyserver/callback.go
2020-11-23 12:19:50 +08:00

32 lines
637 B
Go

package main
import (
"fmt"
"log"
"github.com/474420502/requests"
)
// CallbackServer 处理回调客户端
func CallbackServer(task *Task) {
defer func() {
if err := recover(); err != nil {
log.Println(err)
}
}()
task.lock.Lock()
defer task.lock.Unlock()
if callback, ok := task.data["callback"]; ok {
cburl := callback.(string)
// log.Println(cburl)
_, err := requests.NewSession().Post(cburl).SetBodyAuto(task.data, requests.TypeFormData).Execute()
if err != nil {
log.Println(err)
task.data["error"] = fmt.Sprintf("callback url error: %s", err)
} else {
task.data["status"] = "readied"
}
}
}