Skip to content

Latest commit

 

History

History
60 lines (38 loc) · 1.57 KB

README.md

File metadata and controls

60 lines (38 loc) · 1.57 KB

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.