| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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)
- }
|