Do not log requests to the health endpoint

This commit is contained in:
Alejandro Celaya 2023-10-20 09:26:09 +02:00
parent d419b9d62d
commit 55885b0f25
4 changed files with 29 additions and 3 deletions

View file

@ -45,7 +45,7 @@
"php-middleware/request-id": "^4.1",
"pugx/shortid-php": "^1.1",
"ramsey/uuid": "^4.7",
"shlinkio/shlink-common": "dev-main#8253378 as 5.7",
"shlinkio/shlink-common": "dev-main#4e859a7 as 5.7",
"shlinkio/shlink-config": "dev-main#c0aa01f as 2.5",
"shlinkio/shlink-event-dispatcher": "dev-main#bd3a62b as 3.1",
"shlinkio/shlink-importer": "^5.1",

View file

@ -9,7 +9,6 @@ use Laminas\ServiceManager\Factory\InvokableFactory;
use Psr\EventDispatcher\EventDispatcherInterface;
use Shlinkio\Shlink\Common\Doctrine\EntityRepositoryFactory;
use Shlinkio\Shlink\Config\Factory\ValinorConfigFactory;
use Shlinkio\Shlink\Core\ErrorHandler;
use Shlinkio\Shlink\Core\Options\NotFoundRedirectOptions;
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;

View file

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Rest;
use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Laminas\Stdlib\ArrayUtils\MergeReplaceKey;
use Shlinkio\Shlink\Common\Middleware\AccessLogMiddleware;
return [
'access_logs' => [
'ignored_paths' => [
Action\HealthAction::ROUTE_PATH,
],
],
// This config needs to go in this file in order to override the value defined in shlink-common
ConfigAbstractFactory::class => [
// Use MergeReplaceKey to overwrite what was defined in shlink-common, instead of merging it
AccessLogMiddleware::class => new MergeReplaceKey(
[AccessLogMiddleware::LOGGER_SERVICE_NAME, 'config.access_logs.ignored_paths'],
),
],
];

View file

@ -17,7 +17,7 @@ class HealthAction extends AbstractRestAction
private const STATUS_PASS = 'pass';
private const STATUS_FAIL = 'fail';
protected const ROUTE_PATH = '/health';
public const ROUTE_PATH = '/health';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];
public function __construct(private EntityManagerInterface $em, private AppOptions $options)