gf/frame/gins/gins_httpclient.go
John Guo ae4f14c2e2
add LevelPrint configuration for glog.Logger; add package internal/instance for grouped instance management feature; add default logger for panic message printing if no logger set in gcron.Cron (#2388)
* improve logging feature, add LevelPrint configuration for glog.Logger; add package internal/instance

* improve command build

* add default logger for panic message printing if no logger set

* up

* fix scheduler when timer triggers in less than one second for package gcron

* up
2023-01-06 14:15:30 +08:00

23 lines
691 B
Go

// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gins
import (
"fmt"
"github.com/gogf/gf/v2/internal/instance"
"github.com/gogf/gf/v2/net/gclient"
)
// HttpClient returns an instance of http client with specified name.
func HttpClient(name ...interface{}) *gclient.Client {
var instanceKey = fmt.Sprintf("%s.%v", frameCoreComponentNameHttpClient, name)
return instance.GetOrSetFuncLock(instanceKey, func() interface{} {
return gclient.New()
}).(*gclient.Client)
}