feat(host): add factory-based middleware creation support#266
Merged
j-d-ha merged 4 commits intoDec 21, 2025
Conversation
- Introduced `ILambdaMiddlewareFactory` for custom middleware construction. - Added `UseMiddleware<TFactory>()` extension method in `MiddlewareLambdaApplicationExtensions`. - Enhanced DI container integration for resolving middleware factories. - Included proper handling and disposal for `IAsyncDisposable` and `IDisposable` middlewares.
- Added tests for `UseMiddlewareFactory` with null application argument. - Verified middleware registration and execution using `TestMiddlewareFactory`. - Implemented tests for proper handling of disposable and async disposable middlewares. - Included scenarios tracking middleware creation, invocation, and disposal.
- Documented `ILambdaMiddlewareFactory` for custom middleware creation. - Included example for middleware registration using `UseMiddleware<TFactory>()`. - Demonstrated integration of DI and proper handling of disposal features.
- Replaced hardcoded scope list with a reference to `./.claude/commands/pr.md` for valid scopes. - Clarified where to find the complete list of allowed scope values.
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #266 +/- ##
==========================================
+ Coverage 88.76% 88.87% +0.11%
==========================================
Files 132 132
Lines 3231 3263 +32
Branches 321 322 +1
==========================================
+ Hits 2868 2900 +32
Misses 247 247
Partials 116 116
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
j-d-ha
deleted the
feature/#259-add-ILambdaMiddlewareFactory-interface
branch
December 21, 2025 19:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🚀 Pull Request
📋 Summary
Adds support for factory-based middleware creation through a new
ILambdaMiddlewareFactoryinterface and correspondingUseMiddleware<TFactory>()extension method. This enables scenarios where middleware construction needs to be customized or deferred, with automatic disposal support for middleware that implementsIDisposableorIAsyncDisposable.Key Changes:
ILambdaMiddlewareFactoryinterface in MinimalLambda.AbstractionsUseMiddleware<TFactory>()extension method that resolves factories from the invocation service provider✅ Checklist
🧪 Related Issues or PRs
Closes #259
💬 Notes for Reviewers
The factory pattern enables:
The implementation automatically detects and handles both
IAsyncDisposableandIDisposablemiddleware, prioritizing async disposal when both interfaces are implemented.