Ticket #30101: middleware_syntax_in_docs.diff

File middleware_syntax_in_docs.diff, 1.4 KB (added by Theodore Diamantidis, 6 years ago)

Patch for documentation

  • docs/topics/http/middleware.txt

    diff --git a/docs/topics/http/middleware.txt b/docs/topics/http/middleware.txt
    index 86283af..337290b 100644
    a b A middleware can be written as a function that looks like this::  
    2828    def simple_middleware(get_response):
    2929        # One-time configuration and initialization.
    3030
    31         def middleware(request):
     31        def middleware(request, *args, **kwargs):
    3232            # Code to be executed for each request before
    3333            # the view (and later middleware) are called.
    3434
    35             response = get_response(request)
     35            response = get_response(request, *args, **kwargs)
    3636
    3737            # Code to be executed for each request/response after
    3838            # the view is called.
    Or it can be written as a class whose instances are callable, like this::  
    4848            self.get_response = get_response
    4949            # One-time configuration and initialization.
    5050
    51         def __call__(self, request):
     51        def __call__(self, request, *args, **kwargs):
    5252            # Code to be executed for each request before
    5353            # the view (and later middleware) are called.
    5454
    55             response = self.get_response(request)
     55            response = self.get_response(request, *args, **kwargs)
    5656
    5757            # Code to be executed for each request/response after
    5858            # the view is called.
Back to Top