18 lines
403 B
Go
18 lines
403 B
Go
package httpclient
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// NewHTTPClient 根据配置类型返回对应 HTTPClient 实例
|
|
func NewHTTPClient(clientType string) (HTTPClient, error) {
|
|
switch clientType {
|
|
case "fasthttp":
|
|
return NewFastHTTPClient(), nil
|
|
case "net-http":
|
|
return NewNetHTTPClient(), nil
|
|
default:
|
|
return nil, fmt.Errorf("unsupported client: %s", clientType)
|
|
}
|
|
}
|