From cdabfedeb63adc4226e8e3c6d8329ac1ecfc0a7c Mon Sep 17 00:00:00 2001 From: iVamp Date: Thu, 2 Nov 2023 21:03:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Init.php | 2 +- app/Console/Commands/Works.php | 10 +-- app/Console/Kernel.php | 2 +- app/Http/Controllers/AuthController.php | 7 +- app/Http/Kernel.php | 73 ++++++++++++------ .../Middleware/RedirectIfAuthenticated.php | 2 +- app/Providers/EventServiceProvider.php | 1 - app/Services/PingerService.php | 7 +- app/Services/gRPC/GPBMetadata/Pinger.php | Bin 767 -> 803 bytes app/Services/gRPC/Pinger/PingRequest.php | 22 +++--- app/Services/gRPC/Pinger/PingResponse.php | 20 +++-- app/Services/gRPC/Pinger/PingerInterface.php | 13 ++-- composer.json | 2 +- composer.lock | 2 +- 14 files changed, 96 insertions(+), 67 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index be630f9..3539bec 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -20,7 +20,7 @@ class Init extends Command */ protected $description = '初始化应用程序(用于容器启动时)。'; - /** + /** * Execute the console command. */ public function handle(): void diff --git a/app/Console/Commands/Works.php b/app/Console/Commands/Works.php index 0dbb5da..4522082 100644 --- a/app/Console/Commands/Works.php +++ b/app/Console/Commands/Works.php @@ -2,12 +2,12 @@ namespace App\Console\Commands; -use App\Services\PingerService; -use Spiral\RoadRunner\Worker; -use Illuminate\Console\Command; -use Spiral\RoadRunner\GRPC\Server; -use Spiral\RoadRunner\GRPC\Invoker; use App\Services\gRPC\Pinger\PingerInterface; +use App\Services\PingerService; +use Illuminate\Console\Command; +use Spiral\RoadRunner\GRPC\Invoker; +use Spiral\RoadRunner\GRPC\Server; +use Spiral\RoadRunner\Worker; class Works extends Command { diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e6b9960..4c1dd5a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -20,7 +20,7 @@ protected function schedule(Schedule $schedule): void */ protected function commands(): void { - $this->load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index b568d79..43b3fc8 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -4,17 +4,16 @@ use App\Models\User; use GuzzleHttp\Client; -use Illuminate\Support\Str; -use Illuminate\Http\Request; -use Illuminate\Support\Carbon; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Str; class AuthController extends Controller { private $redirectTo = '/'; - + public function redirect(Request $request) { $request->session()->put('state', $state = Str::random(40)); diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 494c050..13e9456 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -2,7 +2,30 @@ namespace App\Http; +use App\Http\Middleware\Authenticate; +use App\Http\Middleware\EncryptCookies; +use App\Http\Middleware\PreventRequestsDuringMaintenance; +use App\Http\Middleware\RedirectIfAuthenticated; +use App\Http\Middleware\TrimStrings; +use App\Http\Middleware\TrustProxies; +use App\Http\Middleware\ValidateSignature; +use App\Http\Middleware\VerifyCsrfToken; +use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth; +use Illuminate\Auth\Middleware\Authorize; +use Illuminate\Auth\Middleware\EnsureEmailIsVerified; +use Illuminate\Auth\Middleware\RequirePassword; +use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; use Illuminate\Foundation\Http\Kernel as HttpKernel; +use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull; +use Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests; +use Illuminate\Foundation\Http\Middleware\ValidatePostSize; +use Illuminate\Http\Middleware\HandleCors; +use Illuminate\Http\Middleware\SetCacheHeaders; +use Illuminate\Routing\Middleware\SubstituteBindings; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Session\Middleware\AuthenticateSession; +use Illuminate\Session\Middleware\StartSession; +use Illuminate\View\Middleware\ShareErrorsFromSession; class Kernel extends HttpKernel { @@ -15,12 +38,12 @@ class Kernel extends HttpKernel */ protected $middleware = [ // \App\Http\Middleware\TrustHosts::class, - \App\Http\Middleware\TrustProxies::class, - \Illuminate\Http\Middleware\HandleCors::class, - \App\Http\Middleware\PreventRequestsDuringMaintenance::class, - \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, - \App\Http\Middleware\TrimStrings::class, - \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + TrustProxies::class, + HandleCors::class, + PreventRequestsDuringMaintenance::class, + ValidatePostSize::class, + TrimStrings::class, + ConvertEmptyStringsToNull::class, ]; /** @@ -30,18 +53,18 @@ class Kernel extends HttpKernel */ protected $middlewareGroups = [ 'web' => [ - \App\Http\Middleware\EncryptCookies::class, - \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, - \Illuminate\Session\Middleware\StartSession::class, - \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \App\Http\Middleware\VerifyCsrfToken::class, - \Illuminate\Routing\Middleware\SubstituteBindings::class, + EncryptCookies::class, + AddQueuedCookiesToResponse::class, + StartSession::class, + ShareErrorsFromSession::class, + VerifyCsrfToken::class, + SubstituteBindings::class, ], 'api' => [ // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, - \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', - \Illuminate\Routing\Middleware\SubstituteBindings::class, + ThrottleRequests::class . ':api', + SubstituteBindings::class, ], ]; @@ -53,16 +76,16 @@ class Kernel extends HttpKernel * @var array */ protected $middlewareAliases = [ - 'auth' => \App\Http\Middleware\Authenticate::class, - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, - 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, - 'can' => \Illuminate\Auth\Middleware\Authorize::class, - 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, - 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, - 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, - 'signed' => \App\Http\Middleware\ValidateSignature::class, - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, - 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'auth' => Authenticate::class, + 'auth.basic' => AuthenticateWithBasicAuth::class, + 'auth.session' => AuthenticateSession::class, + 'cache.headers' => SetCacheHeaders::class, + 'can' => Authorize::class, + 'guest' => RedirectIfAuthenticated::class, + 'password.confirm' => RequirePassword::class, + 'precognitive' => HandlePrecognitiveRequests::class, + 'signed' => ValidateSignature::class, + 'throttle' => ThrottleRequests::class, + 'verified' => EnsureEmailIsVerified::class, ]; } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index afc78c4..741105d 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -13,7 +13,7 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next + * @param Closure(Request): (Response) $next */ public function handle(Request $request, Closure $next, string ...$guards): Response { diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 2d65aac..87c58d1 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -5,7 +5,6 @@ use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; -use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider { diff --git a/app/Services/PingerService.php b/app/Services/PingerService.php index e288691..f4c498b 100644 --- a/app/Services/PingerService.php +++ b/app/Services/PingerService.php @@ -2,19 +2,18 @@ namespace App\Services; -use Spiral\RoadRunner\GRPC; +use App\Services\gRPC\Pinger\PingerInterface; use App\Services\gRPC\Pinger\PingRequest; use App\Services\gRPC\Pinger\PingResponse; -use App\Services\gRPC\Pinger\PingerInterface; use Spiral\RoadRunner\GRPC\ContextInterface; class PingerService implements PingerInterface { public function ping(ContextInterface $ctx, PingRequest $in): PingResponse - { + { return new PingResponse([ 'status_code' => rand(200, 500) ]); } -} \ No newline at end of file +} diff --git a/app/Services/gRPC/GPBMetadata/Pinger.php b/app/Services/gRPC/GPBMetadata/Pinger.php index 47e0dcf52c61303ed03bd54fb2a9012c09d34948..b00f5e7630f8e6ad28b5094e4782a923afb808b1 100644 GIT binary patch delta 102 zcmey*x|nUkWR}w6RE5dxjOr67B#Uz?06{gF1hG^K^7C^PY!xOeFvd-;Vf1Exzkl!K w6O1dBfi#nZV?jYoOmJ#ZS!Qx-aZF5lP=IqxOh9H{dTJ3!-2^6+$p@J10h}u&CjbBd delta 69 zcmZ3?_MdgavI6rez*AU{7x!B!z=;&k=NZj1qwXE1uQyk_K*ndmJunVG4J V@zmrAOtOrRCU0Oenf!vu8UX)q7BT<; diff --git a/app/Services/gRPC/Pinger/PingRequest.php b/app/Services/gRPC/Pinger/PingRequest.php index df83ce9..4aafe28 100644 --- a/app/Services/gRPC/Pinger/PingRequest.php +++ b/app/Services/gRPC/Pinger/PingRequest.php @@ -4,14 +4,14 @@ namespace App\Services\gRPC\Pinger; -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; +use App\Services\gRPC\GPBMetadata\Pinger; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\Internal\Message; /** * Generated from protobuf message pinger.PingRequest */ -class PingRequest extends \Google\Protobuf\Internal\Message +class PingRequest extends Message { /** * Generated from protobuf field string url = 1; @@ -22,18 +22,20 @@ class PingRequest extends \Google\Protobuf\Internal\Message * Constructor. * * @param array $data { - * Optional. Data for populating the Message object. + * Optional. Data for populating the Message object. * - * @type string $url - * } + * @type string $url + * } */ - public function __construct($data = NULL) { - \App\Services\gRPC\GPBMetadata\Pinger::initOnce(); + public function __construct($data = null) + { + Pinger::initOnce(); parent::__construct($data); } /** * Generated from protobuf field string url = 1; + * * @return string */ public function getUrl() @@ -43,12 +45,14 @@ public function getUrl() /** * Generated from protobuf field string url = 1; + * * @param string $var + * * @return $this */ public function setUrl($var) { - GPBUtil::checkString($var, True); + GPBUtil::checkString($var, true); $this->url = $var; return $this; diff --git a/app/Services/gRPC/Pinger/PingResponse.php b/app/Services/gRPC/Pinger/PingResponse.php index 8dff078..15705d3 100644 --- a/app/Services/gRPC/Pinger/PingResponse.php +++ b/app/Services/gRPC/Pinger/PingResponse.php @@ -4,14 +4,14 @@ namespace App\Services\gRPC\Pinger; -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; +use App\Services\gRPC\GPBMetadata\Pinger; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\Internal\Message; /** * Generated from protobuf message pinger.PingResponse */ -class PingResponse extends \Google\Protobuf\Internal\Message +class PingResponse extends Message { /** * Generated from protobuf field int32 status_code = 1; @@ -22,18 +22,20 @@ class PingResponse extends \Google\Protobuf\Internal\Message * Constructor. * * @param array $data { - * Optional. Data for populating the Message object. + * Optional. Data for populating the Message object. * - * @type int $status_code - * } + * @type int $status_code + * } */ - public function __construct($data = NULL) { - \App\Services\gRPC\GPBMetadata\Pinger::initOnce(); + public function __construct($data = null) + { + Pinger::initOnce(); parent::__construct($data); } /** * Generated from protobuf field int32 status_code = 1; + * * @return int */ public function getStatusCode() @@ -43,7 +45,9 @@ public function getStatusCode() /** * Generated from protobuf field int32 status_code = 1; + * * @param int $var + * * @return $this */ public function setStatusCode($var) diff --git a/app/Services/gRPC/Pinger/PingerInterface.php b/app/Services/gRPC/Pinger/PingerInterface.php index 47a1dc8..56b34b6 100644 --- a/app/Services/gRPC/Pinger/PingerInterface.php +++ b/app/Services/gRPC/Pinger/PingerInterface.php @@ -12,11 +12,12 @@ interface PingerInterface extends GRPC\ServiceInterface public const NAME = "pinger.Pinger"; /** - * @param GRPC\ContextInterface $ctx - * @param PingRequest $in - * @return PingResponse - * - * @throws GRPC\Exception\InvokeException - */ + * @param GRPC\ContextInterface $ctx + * @param PingRequest $in + * + * @return PingResponse + * + * @throws GRPC\Exception\InvokeException + */ public function ping(GRPC\ContextInterface $ctx, PingRequest $in): PingResponse; } diff --git a/composer.json b/composer.json index 82a99dd..2bb45f8 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require-dev": { "fakerphp/faker": "^1.9.1", - "laravel/pint": "^1.0", + "laravel/pint": "^1.13", "laravel/sail": "^1.18", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", diff --git a/composer.lock b/composer.lock index 8bbd213..bfd5c42 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "49bbf2a7ce94713296cca9ba67ed46f2", + "content-hash": "52aa47f1f069d6f6969dfb7089ae1adf", "packages": [ { "name": "brick/math",