|
6 | 6 | use Aws\Api\Service; |
7 | 7 | use Aws\EndpointDiscovery\EndpointDiscoveryMiddleware; |
8 | 8 | use Aws\EndpointV2\EndpointProviderV2; |
| 9 | +use Aws\EndpointV2\EndpointV2Middleware; |
9 | 10 | use Aws\Exception\AwsException; |
10 | 11 | use Aws\Signature\SignatureProvider; |
11 | 12 | use GuzzleHttp\Psr7\Uri; |
@@ -240,7 +241,9 @@ public function __construct(array $args) |
240 | 241 | $this->loadAliases(); |
241 | 242 | $this->addStreamRequestPayload(); |
242 | 243 | $this->addRecursionDetection(); |
243 | | - $this->addRequestBuilder(); |
| 244 | + if ($this->isUseEndpointV2()) { |
| 245 | + $this->addEndpointV2Middleware(); |
| 246 | + } |
244 | 247 |
|
245 | 248 | if (!is_null($this->api->getMetadata('awsQueryCompatible'))) { |
246 | 249 | $this->addQueryCompatibleInputMiddleware($this->api); |
@@ -512,24 +515,18 @@ private function addRecursionDetection() |
512 | 515 | ); |
513 | 516 | } |
514 | 517 |
|
515 | | - /** |
516 | | - * Adds the `builder` middleware such that a client's endpoint |
517 | | - * provider and endpoint resolution arguments can be passed. |
518 | | - */ |
519 | | - private function addRequestBuilder() |
| 518 | + private function addEndpointV2Middleware() |
520 | 519 | { |
521 | | - $handlerList = $this->getHandlerList(); |
522 | | - $serializer = $this->serializer; |
523 | | - $endpointProvider = $this->endpointProvider; |
| 520 | + $list = $this->getHandlerList(); |
524 | 521 | $endpointArgs = $this->getEndpointProviderArgs(); |
525 | 522 |
|
526 | | - $handlerList->prependBuild( |
527 | | - Middleware::requestBuilder( |
528 | | - $serializer, |
529 | | - $endpointProvider, |
| 523 | + $list->prependBuild( |
| 524 | + EndpointV2Middleware::wrap( |
| 525 | + $this->endpointProvider, |
| 526 | + $this->getApi(), |
530 | 527 | $endpointArgs |
531 | 528 | ), |
532 | | - 'builderV2' |
| 529 | + 'endpointV2_middleware' |
533 | 530 | ); |
534 | 531 | } |
535 | 532 |
|
|
0 commit comments