优化是否鉴权
This commit is contained in:
@@ -7,25 +7,22 @@ use GuzzleHttp\Client;
|
|||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use GuzzleHttp\Exception\RequestException;
|
use GuzzleHttp\Exception\RequestException;
|
||||||
|
|
||||||
class BaseClient
|
class BaseClient extends BaseService
|
||||||
{
|
{
|
||||||
private static mixed $_instance;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
protected $client;
|
||||||
* 获取实例
|
|
||||||
* @return null|static
|
protected string $baseUrl = '';
|
||||||
*/
|
protected array $headers = [];
|
||||||
public static function getInstance(): null|static
|
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
$name = get_called_class();
|
$this->isAuth = false;
|
||||||
if (!isset(self::$_instance[$name])) {
|
parent::__construct();
|
||||||
self::$_instance[$name] = new static();
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$_instance[$name];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化请求类
|
* 初始化请求类
|
||||||
* @return $this
|
* @return $this
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class BaseService
|
|||||||
/**
|
/**
|
||||||
* @var bool 是否鉴权
|
* @var bool 是否鉴权
|
||||||
*/
|
*/
|
||||||
private $isAuth = true;
|
protected $isAuth = true;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user