You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Libraries/src/Amazon.Lambda.Annotations/README.md
+48-15
Original file line number
Diff line number
Diff line change
@@ -163,15 +163,37 @@ original declaration should be manually removed.
163
163
## Dependency Injection integration
164
164
165
165
Lambda Annotations supports dependency injection. A class can be marked with a `LambdaStartup` attribute. The class will
166
-
have a `ConfigureServices` method for configuring services.
166
+
have a `ConfigureHostBuilder` method for configuring the host builder. `ConfigureHostBuilder` should return an implementation of `IHostApplicationBuilder`.
167
167
168
-
The services can be injected by either constructor injection or using the `FromServices` attribute on a method parameter of
168
+
Services can be injected by either constructor injection or using the `FromServices` attribute on a method parameter of
169
169
the function decorated with the `LambdaFunction` attribute.
170
170
171
171
Services injected via the constructor have a lifecycle for the length of the Lambda compute container. For each Lambda
172
172
invocation a scope is created and the services injected using the `FromServices` attribute are created within the scope.
173
173
174
-
Example startup class:
174
+
Example startup class using the recommended ConfigureHostBuilder:
public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponseAdd(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequestrequest, Amazon.Lambda.Core.ILambdaContextcontext)
@@ -579,16 +608,20 @@ service has state that should not be preserved per invocation.
0 commit comments