alltube/classes/Middleware/LinkHeaderMiddleware.php

42 lines
864 B
PHP
Raw Normal View History

<?php
2020-10-20 21:13:48 +00:00
namespace Alltube\Middleware;
use Alltube\Factory\ViewFactory;
use Psr\Container\ContainerInterface;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Router;
/**
* Class LinkHeaderMiddleware
* @package Alltube
*/
class LinkHeaderMiddleware
{
/**
* @param Request $request
* @param Response $response
* @param callable $next
* @return mixed
*/
public function __invoke(Request $request, Response $response, callable $next)
{
$uri = ViewFactory::prepareUri($request);
$response = $response->withHeader(
'Link',
2021-10-19 21:14:38 +00:00
implode(
'; ',
[
'<' . $uri->getBasePath() . '/css/style.css>',
2021-10-19 21:14:38 +00:00
'rel=preload', 'as=style'
]
)
);
return $next($request, $response);
}
}