Skip to content

Commit

Permalink
优化:插件机制优化,减少内存占用
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuchunshu committed Feb 14, 2023
1 parent 9548082 commit deee63f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
13 changes: 3 additions & 10 deletions app/Listener/BladeCsrf.php → app/Listener/Boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
*/
namespace App\Listener;

use App\CodeFec\CodeFec;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\BootApplication;
use Hyperf\ViewEngine\Blade;
use Psr\Container\ContainerInterface;

#[Listener]
class BladeCsrf implements ListenerInterface
class Boot implements ListenerInterface
{
/**
* @var ContainerInterface
Expand All @@ -38,13 +38,6 @@ public function listen(): array

public function process(object $event): void
{
Blade::directive('csrf', function () {
$token = csrf_token();
return "<?php echo <<<HTML
<input type='hidden' name='_token' value='{$token}'>
HTML;
; ?>";
});
(new CodeFec())->handle();
}
}
1 change: 0 additions & 1 deletion app/Server/CodeFecServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public function onRequest($request, $response): void
try {
CoordinatorManager::until(Constants::WORKER_START)->yield();

(new CodeFec())->handle();
[$psr7Request, $psr7Response] = $this->initRequestAndResponse($request, $response);

$psr7Request = $this->coreMiddleware->dispatch($psr7Request);
Expand Down

0 comments on commit deee63f

Please sign in to comment.