Commit d62dd571 authored by 谢宇轩's avatar 谢宇轩

fix: 去掉了UUID4的库

parent fa266bfe
......@@ -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": {
......
......@@ -14,9 +14,10 @@ class RequestIDMiddleware implements MiddlewareInterface
/**
* @param string|null $uuid
*/
public function __construct(string $uuid = null){
public function __construct(string $uuid = null)
{
if (!$uuid) {
$uuid = substr(Uuid::uuid4()->toString(), 0, 8);
$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