-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AWS Lambda Annotation Functions never passes through middleware #1875
Comments
Needs reproduction |
@BryZeNtZa Good afternoon. Please refer to #1688 (comment) for similar discussion started a while ago. While on high level it might appear to have some kind of relation to ASP.NET framework:
...
namespace SomeNamespace
{
public class Functions_Add_Generated
{
private readonly ServiceProvider serviceProvider;
public Functions_Add_Generated()
{
SetExecutionEnvironment();
var services = new ServiceCollection();
...
var startup = new LambdaAnnotations_Issue1368.Startup();
startup.ConfigureServices(services);
serviceProvider = services.BuildServiceProvider();
}
public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse Add(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
...
}
}
Hence, there is no concept of ASP.NET's Hence, middleware is not invoked while using annotations. Reference example (using both programming models): https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/cross-service/PhotoAssetManager CCing @normj for any other inputs. Thanks, |
Thanks for your answer @ashishdhingra . However Middleware pattern is a so useful feature in Web development nowadays. AWS AF would definitely find a way to provide it. Thanks. |
@BryZeNtZa I will review this with the team if supporting middleware somehow is feasible given that Annotations framework doesn't leverage ASP.NET pipeline. |
Describe the bug
I'm writing C# Lambda functions to be exposed by the API Gateway service, using the AWS Annotation Framework.
I successfully registered application services in the
ConfigureServices(IServiceCollection services)
method of the Startup.cs file.In order to add some API configurations in the header of all incoming requests (Authorization header, etc.), I registered a middleware via the
Configure(IApplicationBuilder app, IWebHostEnvironment env)
method of the the Startup.cs file.The problem is, the application is completely ignoring the middleware; in other terms, the application never passes through the middleware.
Here is the code:
Lambda function (in Function.cs file):
My Startups.cs file with services registration in ConfigureServices() and middleware registration in Configure() method:
The middleware itself - TbApiConfigurationMiddleware.cs :
Regression Issue
Expected Behavior
I want my API Config Middleware (here TbApiConfigurationMiddleware) to add some API configurations in the header of all incoming requests (Authorization header, etc.).
At least, I want to see that the application is passing through the middleware when a request enters.
Current Behavior
The application never passes through the middleware when a request comes in.
Reproduction Steps
Use Amazon Lambda Annotations Framework guidelines and:
1- Create a serverless Lambda Functions project with the AWS Lambda Annotations Framework with Visual Studio
2- Register a middleware that add a header in the request (whatever header name you want)
3- Create a Lambda function that take an HTTP request and output the header created in the middleware
4- Check that the application passes through the middleware and that the application outputs the header added by the middleware
Possible Solution
No response
Additional Information/Context
I use Visual Studio Community 2022
AWS .NET SDK and/or Package version used
AWSSDK.Core 3.7.400.45
AWSSDK.S3 3.7.405.9
Targeted .NET Platform
.NET 8
Operating System and version
Windows 11
The text was updated successfully, but these errors were encountered: