mirror of
https://github.com/shlinkio/shlink.git
synced 2026-02-28 12:13:13 +08:00
20 lines
532 B
PHP
20 lines
532 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\Common\Middleware;
|
|
|
|
use Psr\Container\ContainerInterface;
|
|
use RKA\Middleware\IpAddress;
|
|
|
|
class IpAddressMiddlewareFactory
|
|
{
|
|
public const REQUEST_ATTR = 'remote_address';
|
|
|
|
public function __invoke(ContainerInterface $container): IpAddress
|
|
{
|
|
$config = $container->get('config');
|
|
$headersToInspect = $config['ip_address_resolution']['headers_to_inspect'] ?? [];
|
|
return new IpAddress(true, [], self::REQUEST_ATTR, $headersToInspect);
|
|
}
|
|
}
|