Description
Add an ILambdaMiddlewareFactory interface to support custom middleware creation logic.
Motivation
Currently, middleware can be registered using UseMiddleware<T>(), but there's no built-in way to customize how middleware instances are created. A factory interface would enable:
- Custom middleware initialization logic
- Advanced dependency injection scenarios
- Middleware pooling or reuse strategies
- Complex constructor parameter resolution
Proposed Interface
public interface ILambdaMiddlewareFactory
{
ILambdaMiddleware Create(Type middlewareType);
}
Or with generics:
public interface ILambdaMiddlewareFactory
{
TMiddleware Create<TMiddleware>() where TMiddleware : ILambdaMiddleware;
}
Implementation Considerations
- Should integrate with the existing middleware pipeline
- Should work seamlessly with
UseMiddleware<T>()
- Consider whether to support both generic and non-generic versions
- Determine whether factory should be registered per middleware type or globally
- Consider lifetime management (transient, scoped, singleton)
Acceptance Criteria
Related
This relates to the existing class-based middleware support introduced in #257.
Description
Add an
ILambdaMiddlewareFactoryinterface to support custom middleware creation logic.Motivation
Currently, middleware can be registered using
UseMiddleware<T>(), but there's no built-in way to customize how middleware instances are created. A factory interface would enable:Proposed Interface
Or with generics:
Implementation Considerations
UseMiddleware<T>()Acceptance Criteria
ILambdaMiddlewareFactoryinterface is added toMinimalLambda.AbstractionsRelated
This relates to the existing class-based middleware support introduced in #257.