Giter Site home page Giter Site logo

jensklose / rka-scheme-and-host-detection-middleware Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akrabat/proxy-detection-middleware

0.0 2.0 0.0 12 KB

PSR-7 middleware to detect scheme and host from proxy headers

License: Other

PHP 100.00%

rka-scheme-and-host-detection-middleware's Introduction

Proxy Scheme and Host detection middleware

Build status

PSR-7 Middleware that determines the scheme and host from the 'X-Forwarded-Proto' and 'X-Forwarded-Host' 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/rka-scheme-and-host-detection-middleware

Usage

In Slim 3:

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

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

    return $response;
});

Testing

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

rka-scheme-and-host-detection-middleware's People

Contributors

akrabat avatar flavioheleno avatar vlakoff avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.