Skip to main content

MiddlewareMixin

This class provides a base implementation for middleware that supports both synchronous and asynchronous request processing. It automatically detects the execution mode based on the provided response handler and manages the transition between sync and async calling conventions. Developers can extend this mixin to implement custom request and response processing logic while maintaining compatibility across different execution environments.

Attributes

AttributeTypeDescription
sync_capableboolean = TrueBoolean flag indicating if the middleware can handle synchronous requests.
async_capableboolean = TrueBoolean flag indicating if the middleware can handle asynchronous requests.

Constructor

Signature

def MiddlewareMixin(
get_response: callable
) - > null

Parameters

NameTypeDescription
get_responsecallableThe next middleware or view in the chain to be called.