You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
635 B

  1. package http
  2. import (
  3. "github.com/seaweedfs/seaweedfs/weed/glog"
  4. util_http_client "github.com/seaweedfs/seaweedfs/weed/util/http/client"
  5. )
  6. var (
  7. globalHttpClient *util_http_client.HTTPClient
  8. )
  9. func NewGlobalHttpClient(opt ...util_http_client.HttpClientOpt) (*util_http_client.HTTPClient, error) {
  10. return util_http_client.NewHttpClient(util_http_client.Client, opt...)
  11. }
  12. func GetGlobalHttpClient() *util_http_client.HTTPClient {
  13. return globalHttpClient
  14. }
  15. func InitGlobalHttpClient() {
  16. var err error
  17. globalHttpClient, err = NewGlobalHttpClient()
  18. if err != nil {
  19. glog.Fatalf("error init global http client: %v", err)
  20. }
  21. }