@@ -96,7 +96,7 @@ public static ApiGatewayEmulatorProcess Startup(RunCommandSettings settings, Can
96
96
PayloadStream = lambdaRequestStream
97
97
} ;
98
98
99
- using var lambdaClient = CreateLambdaServiceClient ( routeConfig ) ;
99
+ using var lambdaClient = CreateLambdaServiceClient ( routeConfig , settings ) ;
100
100
var response = await lambdaClient . InvokeAsync ( invokeRequest ) ;
101
101
102
102
if ( response . FunctionError != null )
@@ -111,13 +111,11 @@ public static ApiGatewayEmulatorProcess Startup(RunCommandSettings settings, Can
111
111
{
112
112
var lambdaResponse = response . ToApiGatewayHttpApiV2ProxyResponse ( ) ;
113
113
await lambdaResponse . ToHttpResponseAsync ( context ) ;
114
- return ;
115
114
}
116
115
else
117
116
{
118
117
var lambdaResponse = response . ToApiGatewayProxyResponse ( settings . ApiGatewayEmulatorMode . Value ) ;
119
118
await lambdaResponse . ToHttpResponseAsync ( context , settings . ApiGatewayEmulatorMode . Value ) ;
120
- return ;
121
119
}
122
120
} ) ;
123
121
@@ -131,12 +129,27 @@ public static ApiGatewayEmulatorProcess Startup(RunCommandSettings settings, Can
131
129
} ;
132
130
}
133
131
134
- private static IAmazonLambda CreateLambdaServiceClient ( ApiGatewayRouteConfig routeConfig )
132
+ /// <summary>
133
+ /// Creates an Amazon Lambda service client with the specified configuration.
134
+ /// </summary>
135
+ /// <param name="routeConfig">The API Gateway route configuration containing the endpoint information.
136
+ /// If the endpoint is specified in routeConfig, it will be used as the service URL.</param>
137
+ /// <param name="settings">The run command settings containing host and port information.
138
+ /// If routeConfig endpoint is null, the service URL will be constructed using settings.Host and settings.Port.</param>
139
+ /// <returns>An instance of IAmazonLambda configured with the specified endpoint and credentials.</returns>
140
+ /// <remarks>
141
+ /// The function uses hard-coded AWS credentials ("accessKey", "secretKey") for authentication since they are not actually being used.
142
+ /// The service URL is determined by either:
143
+ /// - Using routeConfig.Endpoint if it's not null
144
+ /// - Combining settings.Host and settings.Port if routeConfig.Endpoint is null
145
+ /// </remarks>
146
+ private static IAmazonLambda CreateLambdaServiceClient ( ApiGatewayRouteConfig routeConfig , RunCommandSettings settings )
135
147
{
136
- // TODO: Handle routeConfig.Endpoint to null and use the settings versions of runtime.
148
+ var endpoint = routeConfig . Endpoint ?? $ "http://{ settings . Host } :{ settings . Port } ";
149
+
137
150
var lambdaConfig = new AmazonLambdaConfig
138
151
{
139
- ServiceURL = routeConfig . Endpoint
152
+ ServiceURL = endpoint
140
153
} ;
141
154
142
155
return new AmazonLambdaClient ( new Amazon . Runtime . BasicAWSCredentials ( "accessKey" , "secretKey" ) , lambdaConfig ) ;
0 commit comments