Skeleton is ready

This commit is contained in:
2026-01-05 16:33:20 +04:00
commit eeaf43ab5d
89 changed files with 2704 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace App\Kernel\Http\Middleware;
use App\Kernel\Http\ContentType;
use App\Kernel\Http\Header;
use App\Kernel\Object\Enum;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
class CheckAcceptHeader
{
public function handle(Request $request, Closure $next): Response
{
$headerFound = false;
if ($this->acceptApplicationJson($request)) {
$headerFound = true;
}
if ($request->isMethod('OPTIONS') || $headerFound) {
return $next($request);
}
throw new NotAcceptableHttpException('Valid accept header not found');
}
private function acceptApplicationJson(Request $request): bool
{
$passedHeader = $request->headers->get(Header::Accept->value);
$expectedHeader = Enum::value(ContentType::ApplicationJson);
return $passedHeader === $expectedHeader;
}
}