Commit bd7e6458 authored by 谢宇轩's avatar 谢宇轩 😅

Merge branch 'FeatDelUUID' into 'master'

fix: 修改了自定义的RequestID赋予的逻辑

See merge request back-end/easy-http-sdk!6
parents d93c9898 f33ef6c0
......@@ -160,12 +160,15 @@ class SdkRequest extends Request
/**
* 使用 RequestID 中间件
*
* @param string|null $uuid
* @param string $uuid
* @return SdkRequest
*/
public function withRequestID(?string $uuid = null): self
public function withRequestID(string $uuid = ""): self
{
$this->uuid = $uuid ?? "";
if (empty($uuid)) {
$uuid = sprintf('%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff));
}
$this->uuid = $uuid;
$RequestIDMiddleware = new RequestIDMiddleware($this->uuid);
$this->middlewares[] = $RequestIDMiddleware;
return $this;
......
......@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Jiwei\EasyHttpSdk\Middleware;
use Psr\Http\Message\RequestInterface;
use Ramsey\Uuid\Uuid;
class RequestIDMiddleware implements MiddlewareInterface
{
......@@ -16,9 +15,6 @@ class RequestIDMiddleware implements MiddlewareInterface
*/
public function __construct(string $uuid = "")
{
if (empty($uuid)) {
$uuid = sprintf('%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff));
}
$this->uuid = $uuid;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment