Feature: Middleware Enhancement #20
Merged
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.
🚀 Feature: Advanced Middleware Architecture System
📋 Overview
This PR introduces significant improvements to the middleware architecture in PySpring, providing developers with powerful tools for managing middleware execution order with fine-grained control and a comprehensive API for middleware manipulation.
✨ New Features
🔧 Middleware Architecture Overhaul
MiddlewareRegistry: Transformed from abstract class to fully functional concrete implementationMiddlewareConfiguration: New configuration class for declarative middleware setup🔄 Breaking Changes
MiddlewareRegistry Changes
MiddlewareRegistrywas an abstract class requiring subclassingMiddlewareRegistryis now a concrete class with full implementationMiddlewareConfigurationimplementationsOld Pattern:
New Pattern:
⚙️
MiddlewareConfiguration🎯 Complete API Reference
add_middleware(middleware)registry.add_middleware(AuthMiddleware)add_before(target, new)registry.add_before(AuthMiddleware, CorsMiddleware)add_after(target, new)registry.add_after(AuthMiddleware, LoggingMiddleware)add_at_index(index, middleware)registry.add_at_index(0, SecurityMiddleware)remove_middleware(middleware)registry.remove_middleware(OldMiddleware)has_middleware(middleware)registry.has_middleware(AuthMiddleware)get_middleware_index(middleware)registry.get_middleware_index(AuthMiddleware)get_middleware_count()registry.get_middleware_count()get_middleware_classes()registry.get_middleware_classes()clear_middlewares()registry.clear_middlewares()