mirror of
https://github.com/shlinkio/shlink.git
synced 2025-01-22 06:23:20 -06:00
Slight improvements on RoadRunner config
This commit is contained in:
parent
e9ec32b3c3
commit
846802c003
@ -2,6 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use function Shlinkio\Shlink\Config\env;
|
||||
use function Shlinkio\Shlink\Config\swooleIsInstalled;
|
||||
|
||||
return [
|
||||
@ -10,8 +11,8 @@ return [
|
||||
'domain' => [
|
||||
'schema' => 'http',
|
||||
'hostname' => sprintf('localhost:%s', match (true) {
|
||||
PHP_SAPI === 'cli' && env('RR_MODE') !== null => '8800', // Roadrunner
|
||||
swooleIsInstalled() => '8080', // Swoole
|
||||
PHP_SAPI === 'cli' => '8800', // Roadrunner
|
||||
default => '8000', // FPM
|
||||
}),
|
||||
],
|
||||
|
@ -42,10 +42,12 @@ logs:
|
||||
level: debug
|
||||
|
||||
reload:
|
||||
enabled: true
|
||||
interval: 1s
|
||||
patterns: ['.php', '.yml', '.yaml']
|
||||
services:
|
||||
http:
|
||||
dirs: ['.']
|
||||
dirs: ['../..']
|
||||
recursive: true
|
||||
jobs:
|
||||
dirs: ['../..']
|
||||
recursive: true
|
||||
|
@ -9,7 +9,7 @@ use Shlinkio\Shlink\EventDispatcher\Util\JsonUnserializable;
|
||||
|
||||
abstract class AbstractVisitEvent implements JsonSerializable, JsonUnserializable
|
||||
{
|
||||
public function __construct(public readonly string $visitId)
|
||||
final public function __construct(public readonly string $visitId)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,18 @@ namespace Shlinkio\Shlink\Core\EventDispatcher\Event;
|
||||
|
||||
final class UrlVisited extends AbstractVisitEvent
|
||||
{
|
||||
public function __construct(string $visitId, public readonly ?string $originalIpAddress = null)
|
||||
private ?string $originalIpAddress = null;
|
||||
|
||||
public static function withOriginalIpAddress(string $visitId, ?string $originalIpAddress): self
|
||||
{
|
||||
parent::__construct($visitId);
|
||||
$instance = new self($visitId);
|
||||
$instance->originalIpAddress = $originalIpAddress;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function originalIpAddress(): ?string
|
||||
{
|
||||
return $this->originalIpAddress;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class LocateVisit
|
||||
return;
|
||||
}
|
||||
|
||||
$this->locateVisit($visitId, $shortUrlVisited->originalIpAddress, $visit);
|
||||
$this->locateVisit($visitId, $shortUrlVisited->originalIpAddress(), $visit);
|
||||
$this->eventDispatcher->dispatch(new VisitLocated($visitId));
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,6 @@ class VisitsTracker implements VisitsTrackerInterface
|
||||
$this->em->persist($visit);
|
||||
$this->em->flush();
|
||||
|
||||
$this->eventDispatcher->dispatch(new UrlVisited($visit->getId(), $visitor->remoteAddress));
|
||||
$this->eventDispatcher->dispatch(UrlVisited::withOriginalIpAddress($visit->getId(), $visitor->remoteAddress));
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class LocateVisitTest extends TestCase
|
||||
{
|
||||
$ipAddr = $originalIpAddress ?? $visit->getRemoteAddr();
|
||||
$location = new Location('', '', '', '', 0.0, 0.0, '');
|
||||
$event = new UrlVisited('123', $originalIpAddress);
|
||||
$event = UrlVisited::withOriginalIpAddress('123', $originalIpAddress);
|
||||
|
||||
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
||||
$flush = $this->em->flush()->will(function (): void {
|
||||
|
@ -11,14 +11,14 @@ use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class DropDefaultDomainFromRequestMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function __construct(private string $defaultDomain)
|
||||
public function __construct(private readonly string $defaultDomain)
|
||||
{
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
/** @var array $body */
|
||||
$body = $request->getParsedBody();
|
||||
$body = $request->getParsedBody() ?? [];
|
||||
$request = $request->withQueryParams($this->sanitizeDomainFromPayload($request->getQueryParams()))
|
||||
->withParsedBody($this->sanitizeDomainFromPayload($body));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user