|
package utils |
|
|
|
import ( |
|
"crypto/tls" |
|
"fmt" |
|
"github.com/go-resty/resty/v2" |
|
"time" |
|
) |
|
|
|
var ( |
|
RestySSEClient = resty.New(). |
|
SetTimeout(3 * time.Minute). |
|
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}). |
|
SetDoNotParseResponse(true). |
|
SetHeaders(map[string]string{ |
|
"Content-Type": "application/json", |
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", |
|
"x-client-locale": "zh_CN", |
|
}). |
|
OnAfterResponse(func(c *resty.Client, resp *resty.Response) error { |
|
|
|
if resp.StatusCode() != 200 { |
|
return fmt.Errorf("monica API error: status %d, body: %s", |
|
resp.StatusCode(), resp.String()) |
|
} |
|
return nil |
|
}) |
|
|
|
RestyDefaultClient = resty.New(). |
|
SetTimeout(time.Second * 30). |
|
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}). |
|
SetHeaders(map[string]string{ |
|
"Content-Type": "application/json", |
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", |
|
}). |
|
OnAfterResponse(func(c *resty.Client, resp *resty.Response) error { |
|
|
|
if resp.StatusCode() != 200 { |
|
return fmt.Errorf("monica API error: status %d, body: %s", |
|
resp.StatusCode(), resp.String()) |
|
} |
|
return nil |
|
}) |
|
) |
|
|