HttpClientRouter
in package
implements
HttpClientRouterInterface
FinalYes
{@inheritdoc}
Tags
Table of Contents
Interfaces
- HttpClientRouterInterface
- Route a request to a specific client in the stack based using a RequestMatcher.
Properties
- $clients : array<string|int, FlexibleHttpClient}>
Methods
- addClient() : void
- Add a client to the router.
- sendAsyncRequest() : Promise
- Sends a PSR-7 request in an asynchronous way.
- sendRequest() : ResponseInterface
- Sends a PSR-7 request and returns a PSR-7 response.
- chooseHttpClient() : FlexibleHttpClient
- Choose an HTTP client given a specific request.
Properties
$clients
private
array<string|int, FlexibleHttpClient}>
$clients
= []
Methods
addClient()
Add a client to the router.
public
addClient(ClientInterface|HttpAsyncClient $client, RequestMatcher $requestMatcher) : void
Parameters
- $client : ClientInterface|HttpAsyncClient
- $requestMatcher : RequestMatcher
sendAsyncRequest()
Sends a PSR-7 request in an asynchronous way.
public
sendAsyncRequest(RequestInterface $request) : Promise
Parameters
- $request : RequestInterface
Return values
Promise —resolves a PSR-7 Response or fails with an Http\Client\Exception
sendRequest()
Sends a PSR-7 request and returns a PSR-7 response.
public
sendRequest(RequestInterface $request) : ResponseInterface
Parameters
- $request : RequestInterface
Return values
ResponseInterfacechooseHttpClient()
Choose an HTTP client given a specific request.
private
chooseHttpClient(RequestInterface $request) : FlexibleHttpClient
Parameters
- $request : RequestInterface