mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-24 01:17:56 +08:00
28 lines
635 B
Go
28 lines
635 B
Go
|
package http
|
||
|
|
||
|
import (
|
||
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||
|
util_http_client "github.com/seaweedfs/seaweedfs/weed/util/http/client"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
globalHttpClient *util_http_client.HTTPClient
|
||
|
)
|
||
|
|
||
|
func NewGlobalHttpClient(opt ...util_http_client.HttpClientOpt) (*util_http_client.HTTPClient, error) {
|
||
|
return util_http_client.NewHttpClient(util_http_client.Client, opt...)
|
||
|
}
|
||
|
|
||
|
func GetGlobalHttpClient() *util_http_client.HTTPClient {
|
||
|
return globalHttpClient
|
||
|
}
|
||
|
|
||
|
func InitGlobalHttpClient() {
|
||
|
var err error
|
||
|
|
||
|
globalHttpClient, err = NewGlobalHttpClient()
|
||
|
if err != nil {
|
||
|
glog.Fatalf("error init global http client: %v", err)
|
||
|
}
|
||
|
}
|