Files
wh-api/app/Context/ApiUrlContext.php
ykxiao 8a3ab17b25
Some checks failed
Build Docker / build (push) Has been cancelled
增加基础配置
2025-07-12 11:59:33 +08:00

54 lines
1.1 KiB
PHP

<?php
/**
* Author: ykxiao
* Date: 2025/7/11
* Time: 下午9:00
* Description:
*
* (c) ykxiao <yk_9001@hotmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
declare(strict_types=1);
namespace App\Context;
use Hyperf\Context\Context;
/**
* Author: ykxiao
* Date: 2025/7/11
* Time: 下午9:00
* Description: ApiUrlContext. 请求url上下文
*
* (c) ykxiao <yk_9001@hotmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
class ApiUrlContext
{
private const string API_URL_KEY = 'api_url';
public static function setApiUrl(string $apiUrl): void
{
Context::set(self::API_URL_KEY, $apiUrl);
}
public static function getApiUrl(): ?string
{
return Context::get(self::API_URL_KEY);
}
public static function clearApiUrl(): void
{
Context::set(self::API_URL_KEY, null);
}
public static function hasApiUrl(): bool
{
return Context::has(self::API_URL_KEY);
}
}