diff options
Diffstat (limited to 'django/utils/decorators.py')
| -rw-r--r-- | django/utils/decorators.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/django/utils/decorators.py b/django/utils/decorators.py index bb2e498e46..5c9a5d01c7 100644 --- a/django/utils/decorators.py +++ b/django/utils/decorators.py @@ -150,3 +150,30 @@ def make_middleware_decorator(middleware_class): return _wrapped_view return _decorator return _make_decorator + + +def sync_and_async_middleware(func): + """ + Mark a middleware factory as returning a hybrid middleware supporting both + types of request. + """ + func.sync_capable = True + func.async_capable = True + return func + + +def sync_only_middleware(func): + """ + Mark a middleware factory as returning a sync middleware. + This is the default. + """ + func.sync_capable = True + func.async_capable = False + return func + + +def async_only_middleware(func): + """Mark a middleware factory as returning an async middleware.""" + func.sync_capable = False + func.async_capable = True + return func |
