This commit is contained in:
xl
2024-08-29 17:14:37 +08:00
parent 080cd6ab92
commit 8811f2bcd6
2 changed files with 12 additions and 2 deletions
+10 -1
View File
@@ -16,6 +16,15 @@ class ValidatorMiddleware implements MiddlewareInterface
{
/**
* @param string $class
* @param string $method
*/
public function __construct(public string $class, public string $method)
{
}
/**
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
@@ -24,7 +33,7 @@ class ValidatorMiddleware implements MiddlewareInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$validator = Middleware::getValidator($request->getMethod() . '::' . $request->getUri()->getPath());
$validator = Middleware::getValidator($this->class, $this->method);
if (!$validator->run($request)) {
return di(ResponseInterface::class)->html($validator->error(), 415);
} else {