Skip to content

Commit 9189ffb

Browse files
committed
Fix endpoint resolver of APIGatewayManagementClient
1 parent 95320fe commit 9189ffb

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

aws/api_gateway_websocket_v2.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,11 @@ func (v v2api) PostToConnection(ctx context.Context, connectionID string, data [
3030
// NewAPIGatewayManagementClientV2 creates a new API Gateway Management Client instance from the provided parameters. The
3131
// new client will have a custom endpoint that resolves to the application's deployed API.
3232
func NewAPIGatewayManagementClientV2(conf *aws.Config, domain, stage string) APIGatewayManagementAPI {
33-
localConf := conf.Copy()
34-
localConf.EndpointResolver = aws.EndpointResolverFunc(func(service, region string) (aws.Endpoint, error) {
35-
if service != apigatewaymanagementapi.ServiceID {
36-
return aws.Endpoint{}, &aws.EndpointNotFoundError{}
37-
} else {
38-
var endpoint url.URL
39-
endpoint.Path = stage
40-
endpoint.Host = domain
41-
endpoint.Scheme = "https"
42-
return aws.Endpoint{
43-
SigningRegion: region,
44-
URL: endpoint.String(),
45-
}, nil
46-
}
47-
})
48-
49-
return &v2api{apigatewaymanagementapi.NewFromConfig(localConf)}
33+
var endpoint url.URL
34+
endpoint.Path = stage
35+
endpoint.Host = domain
36+
endpoint.Scheme = "https"
37+
return &v2api{apigatewaymanagementapi.NewFromConfig(conf.Copy(), func(o *apigatewaymanagementapi.Options) {
38+
o.BaseEndpoint = aws.String(endpoint.String())
39+
})}
5040
}

0 commit comments

Comments
 (0)