Skip to content

http-message-strategies-interop/proxy

 
 

Repository files navigation

HMS fork of middlewares/proxy

ServerAction to create a http proxy using Guzzle.

Requirements

Example

$target = new Uri('http://api.example.com');
$proxy = new HMS\Proxy($target);
$response = $proxy(new ServerRequest());

Slim Example

// index.php
use HMS\Proxy;
use Zend\Diactoros\Uri;

require 'vendor/autoload.php';

$app = new \Slim\App;
$app->any('/{_:.*}', new Proxy(new Uri('http://httpbin.org')));
$app->run();
# run built-in web server
$ php -S localhost:8000

# open your browser
$ xdg-open http://localhost:8000

Options

__construct(Psr\Http\Message\UriInterface $uri)

The target of the proxy.

client(GuzzleHttp\ClientInterface $client)

Instance of the client used to execute the requests. If it's not provided, an instance of GuzzleHttp\Client is created automatically.

options(array $options)

Options passed to the guzzle client. See the guzzle documentation for more information

Related


The MIT License (MIT). Please see LICENSE for more information.

About

HMS fork of middlewares/proxy

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%