mirror of
https://github.com/flarum/framework.git
synced 2024-11-26 10:14:16 +08:00
added optional powered-by header (#2618)
This commit is contained in:
parent
84ded0ce50
commit
4b0ad6972d
|
@ -67,7 +67,8 @@ class ForumServiceProvider extends AbstractServiceProvider
|
|||
HttpMiddleware\SetLocale::class,
|
||||
'flarum.forum.route_resolver',
|
||||
HttpMiddleware\CheckCsrfToken::class,
|
||||
HttpMiddleware\ShareErrorsFromSession::class
|
||||
HttpMiddleware\ShareErrorsFromSession::class,
|
||||
HttpMiddleware\FlarumPromotionHeader::class,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
37
src/Http/Middleware/FlarumPromotionHeader.php
Normal file
37
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;
|
||||
}
|
||||
}
|
|
@ -55,6 +55,7 @@ class StoreConfig implements Step, ReversibleStep
|
|||
{
|
||||
return [
|
||||
'debug' => $this->debugMode,
|
||||
'poweredByHeader' => true,
|
||||
'database' => $this->dbConfig->toArray(),
|
||||
'url' => (string) $this->baseUrl,
|
||||
'paths' => $this->getPathsConfig(),
|
||||
|
|
Loading…
Reference in New Issue
Block a user