Refactoring, logging improvements
This commit is contained in:
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Mercureact\Http\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class RequestException extends Exception
|
||||
{
|
||||
const ERR_BAD_REQUEST = 51001;
|
||||
const ERR_BAD_REQUEST_DATA = 51002;
|
||||
const ERR_INVALID_REQUEST_DATA = 51003;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Mercureact\Http\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class SecurityException extends Exception
|
||||
{
|
||||
const ERR_ACCESS_DENIED = 50001;
|
||||
const ERR_NO_PERMISSION = 50002;
|
||||
}
|
@ -6,8 +6,8 @@ use NoccyLabs\Mercureact\Broker\Message;
|
||||
use NoccyLabs\Mercureact\Broker\SseSubscriber;
|
||||
use NoccyLabs\Mercureact\Broker\TopicManager;
|
||||
use NoccyLabs\Mercureact\Configuration;
|
||||
use NoccyLabs\Mercureact\Http\Exception\RequestException;
|
||||
use NoccyLabs\Mercureact\Http\Exception\SecurityException;
|
||||
use NoccyLabs\Mercureact\Exception\RequestException;
|
||||
use NoccyLabs\Mercureact\Exception\SecurityException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use React\EventLoop\Loop;
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace NoccyLabs\Mercureact\Http\Middleware;
|
||||
|
||||
use NoccyLabs\Mercureact\Configuration;
|
||||
use NoccyLabs\Mercureact\Http\Exception\SecurityException;
|
||||
use NoccyLabs\Mercureact\Exception\SecurityException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace NoccyLabs\Mercureact\Http\Middleware;
|
||||
|
||||
use NoccyLabs\Mercureact\Configuration;
|
||||
use NoccyLabs\Mercureact\Http\Exception\SecurityException;
|
||||
use NoccyLabs\Mercureact\Exception\SecurityException;
|
||||
use NoccyLabs\SimpleJWT\JWTToken;
|
||||
use NoccyLabs\SimpleJWT\Key\JWTPlaintextKey;
|
||||
use NoccyLabs\SimpleJWT\Validator\JWTValidator;
|
||||
|
@ -54,8 +54,13 @@ class Server
|
||||
$this->config = $config;
|
||||
|
||||
$this->logger = $logger ?? new NullLogger();
|
||||
if ($logger instanceof Logger) {
|
||||
$topicLogger = $logger->withName("broker");
|
||||
} else {
|
||||
$topicLogger = $this->logger;
|
||||
}
|
||||
|
||||
$this->topicManager = new TopicManager();
|
||||
$this->topicManager = new TopicManager($topicLogger);
|
||||
$this->loop->addPeriodicTimer(30, function () {
|
||||
$this->topicManager->garbageCollect();
|
||||
});
|
||||
|
Reference in New Issue
Block a user