castopod/modules/Api/Rest/V1/Filters/ApiFilter.php

26 lines
645 B
PHP

<?php
declare(strict_types=1);
namespace Modules\Api\Rest\V1\Filters;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
class ApiFilter implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null): void
{
if (! getenv('REST_API_ENABLED')) {
throw PageNotFoundException::forPageNotFound();
}
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void
{
// Do something here
}
}