mirror of
https://github.com/flarum/core.git
synced 2025-07-21 08:41:17 +02:00
added optional powered-by header (#2618)
This commit is contained in:
37
framework/core/src/Http/Middleware/FlarumPromotionHeader.php
Normal file
37
framework/core/src/Http/Middleware/FlarumPromotionHeader.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Http\Middleware;
|
||||
|
||||
use Flarum\Foundation\Config;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface as Middleware;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class FlarumPromotionHeader implements Middleware
|
||||
{
|
||||
protected $enabled = true;
|
||||
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->enabled = $config['poweredByHeader'] ?? true;
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$response = $handler->handle($request);
|
||||
|
||||
if ($this->enabled) {
|
||||
$response = $response->withAddedHeader('X-Powered-By', 'Flarum');
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user