定制 akrabat/proxy-detection-middleware 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

akrabat/proxy-detection-middleware

最新稳定版本:1.1

Composer 安装命令:

composer require akrabat/proxy-detection-middleware

包简介

PSR-7/PSR-15 Middleware that determines the scheme, host and port from the 'X-Forwarded-Proto', 'X-Forwarded-Host' and 'X-Forwarded-Port' headers and updates the Request's Uri object.

README 文档

README

PSR-15 Middleware that determines the scheme, host and port from the 'X-Forwarded-Proto', 'X-Forwarded-Host' and 'X-Forwarded-Port' headers and updates the Request's Uri object.

You can set a list of proxies that are trusted as the second constructor parameter. If this list is set, then the proxy headers will only be checked if the REMOTE_ADDR is in the trusted list.

Installation

composer require akrabat/proxy-detection-middleware

Usage

In Slim 3:

$trustedProxies = ['10.0.0.1', '10.0.0.2'];
$app->add(new RKA\Middleware\ProxyDetection($trustedProxies));

$app->get('/', function ($request, $response, $args) {
    $scheme = $request->getUri()->getScheme();
    $host = $request->getUri()->getHost();
    $port = $request->getUri()->getPort();

    return $response;
});

Testing

  • Code coverage: $ vendor/bin/phpcs
  • Unit tests: $ vendor/bin/phpunit
  • Code coverage: $ vendor/bin/phpunit --coverage-html ./build

统计信息

  • 总下载量: 79.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 31
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 31
  • Watchers: 4
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-09-11