package fwh_pro import ( "fwh-toolbox-server/utils/httpClient" "net/http" "net/url" "time" ) const ( timeout time.Duration = 60 // fwh请求超时60s ) // FwhHttpInit func FwhHttpInit() { httpClient.RegisterLogin(reLogin) } // 仅用户登录或者不需要token的请求 func FwhHttpGetWithoutToken(url string, params url.Values) (*httpClient.Response, error) { t := timeout opt := httpClient.HttpClientOptions{ Timeout: &t, Header: &http.Header{ "Accept": {"application/json", "text/plain", "*/*"}, }, } return httpClient.HttpGet(url, params, &opt) } func FwhHttpGet(url string, params url.Values) (*httpClient.Response, error) { t := timeout opt := httpClient.HttpClientOptions{ Timeout: &t, Header: &http.Header{ "Logintoken": {getLoginToken()}, "Accept": {"application/json", "text/plain", "*/*"}, }, } return httpClient.HttpGet(url, params, &opt) } // 仅用户登录或者不需要token的请求 func FwhHttpPostWithoutToken(url string, body any) (*httpClient.Response, error) { t := timeout opt := httpClient.HttpClientOptions{ Timeout: &t, Header: &http.Header{ "Accept": {"application/json", "text/plain", "*/*"}, }, } return httpClient.HttpPost(url, body, &opt) } func FwhHttpPost(url string, body any) (*httpClient.Response, error) { t := timeout opt := httpClient.HttpClientOptions{ Timeout: &t, Header: &http.Header{ "Logintoken": {getLoginToken()}, "Accept": {"application/json", "text/plain", "*/*"}, }, } return httpClient.HttpPost(url, body, &opt) }