1
0
Fork 0
Manager/app/middleware/Middleware.php

23 lines
578 B
PHP
Raw Permalink Normal View History

2023-08-29 11:55:12 +00:00
<?php
declare(strict_types=1);
namespace Mcp\Middleware;
2023-09-15 17:19:45 +00:00
/**
* Middleware implementations can be registered for a RequestHandler.
*
* If this is done, request processing continues only if Middleware::canAccess() returns true.
*/
2023-08-29 11:55:12 +00:00
interface Middleware
{
2023-09-15 17:19:45 +00:00
/**
* Returns true if the request should be processed, i.e. if the client has permissionn to perform this request.
*/
2023-08-29 11:55:12 +00:00
public function canAccess(): bool;
2023-09-15 17:19:45 +00:00
/**
* Called when canAcces() returns false, e.g. to redirect unauthorized users.
*/
2023-08-29 11:55:12 +00:00
public function handleUnauthorized(): void;
2023-09-15 17:19:45 +00:00
}