Skip to content

middleware

django_spire.metric.domain.statistic.middleware

StatisticClickMiddleware

Source code in django_spire/metric/domain/statistic/middleware.py
def __init__(
    self, get_response: Callable[[HttpRequest], HttpResponse], *, threaded: bool = True
) -> None:
    self.get_response = get_response
    self.threaded = threaded

get_response = get_response instance-attribute

threaded = threaded instance-attribute

__call__

Source code in django_spire/metric/domain/statistic/middleware.py
def __call__(self, request: HttpRequest) -> HttpResponse:
    response = self.get_response(request)

    if self._should_track(request, response):
        self._dispatch_click(request)

    return response