24 lines
513 B
Go
24 lines
513 B
Go
|
package cwclient
|
||
|
|
||
|
import "encoding/json"
|
||
|
|
||
|
// Callback 发送代理连接获取内容后的回调函数
|
||
|
type Callback struct {
|
||
|
label string
|
||
|
hash string
|
||
|
Do func(cxt *CallbackContext)
|
||
|
}
|
||
|
|
||
|
// CallbackContext Callback上下文
|
||
|
type CallbackContext struct {
|
||
|
TaskID string
|
||
|
Content string
|
||
|
Error error
|
||
|
Carry interface{} // 传递的参数.
|
||
|
}
|
||
|
|
||
|
// ContentJSON 返回 json反序列化的对象
|
||
|
func (cxt *CallbackContext) ContentJSON(obj interface{}) error {
|
||
|
return json.Unmarshal([]byte(cxt.Content), obj)
|
||
|
}
|