Added middleware that mitigates big error traces being logged for those not using mercure

This commit is contained in:
Alejandro Celaya
2022-02-20 10:36:54 +01:00
parent 5affe64b61
commit 6983f9b2bf
5 changed files with 47 additions and 11 deletions

View File

@@ -10,7 +10,6 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Shlinkio\Shlink\Common\Mercure\JwtProviderInterface;
use Shlinkio\Shlink\Rest\Exception\MercureException;
use Throwable;
use function sprintf;
@@ -32,12 +31,7 @@ class MercureInfoAction extends AbstractRestAction
$days = $this->mercureConfig['jwt_days_duration'] ?? 1;
$expiresAt = Chronos::now()->addDays($days);
try {
$jwt = $this->jwtProvider->buildSubscriptionToken($expiresAt);
} catch (Throwable $e) {
throw MercureException::mercureNotConfigured($e);
}
$jwt = $this->jwtProvider->buildSubscriptionToken($expiresAt);
return new JsonResponse([
'mercureHubUrl' => sprintf('%s/.well-known/mercure', $hubUrl),