You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Middleware;
|
|
|
|
use App\Service\AppService;
|
|
use Hyperf\Context\Context;
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
use Hyperf\HttpServer\Contract\ResponseInterface as HttpResponse;
|
|
use Hyperf\Contract\ContainerInterface;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
use Psr\Http\Server\MiddlewareInterface;
|
|
use Psr\Http\Server\RequestHandlerInterface;
|
|
|
|
class AppAuthMiddleWare implements MiddlewareInterface
|
|
{
|
|
protected ContainerInterface $container;
|
|
|
|
protected RequestInterface $request;
|
|
|
|
protected HttpResponse $response;
|
|
|
|
public function __construct(ContainerInterface $container, HttpResponse $response, RequestInterface $request)
|
|
{
|
|
$this->container = $container;
|
|
$this->response = $response;
|
|
$this->request = $request;
|
|
}
|
|
|
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
|
{
|
|
$params = $this->request->all();
|
|
/**
|
|
* @var AppService $appService
|
|
*/
|
|
$appService = $this->container->make(AppService::class);
|
|
$app = $appService->checkSign($params);
|
|
Context::set('app', $app);
|
|
|
|
return $handler->handle($request);
|
|
}
|
|
}
|