Commit 83a0791a authored by 谢宇轩's avatar 谢宇轩 😅

Merge branch 'FeatDelUUID' into 'master'

Feat: del uuid library require

See merge request back-end/easy-http-sdk!4
parents c0eda261 e4d0a1a3
......@@ -21,7 +21,6 @@
"symfony/cache": "^5.4",
"yosymfony/toml": "^1.0",
"guzzlehttp/guzzle": "^7.5",
"ramsey/uuid": "~3.8.0",
"ext-json": "*"
},
"require-dev": {
......
......@@ -12,11 +12,12 @@ class RequestIDMiddleware implements MiddlewareInterface
protected $uuid;
/**
* @param string|null $uuid
* @param string $uuid
*/
public function __construct(string $uuid = null){
if (!$uuid) {
$uuid = substr(Uuid::uuid4()->toString(), 0, 8);
public function __construct(string $uuid = "")
{
if (empty($uuid)) {
$uuid = sprintf('%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff));
}
$this->uuid = $uuid;
}
......@@ -31,7 +32,7 @@ class RequestIDMiddleware implements MiddlewareInterface
{
return function (
RequestInterface $request,
array $options
array $options
) use ($handler) {
$request = $request->withHeader("X-Request-ID", $this->uuid);
return $handler($request, $options);
......
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