
    8Cf                        d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
mZmZ d dlmZ  G d de      Z G d	 d
      Zy)    )annotations)deque)IntEnumauto)count)DequeSequenceUnion)MiddlewareTypec                  (    e Zd Z e       Z e       Zy)MiddlewareLocationN)__name__
__module____qualname__r   REQUESTRESPONSE     P/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/sanic/middleware.pyr   r      s    fGvHr   r   c                      e Zd ZU dZ e       Zded<   dZ	 d	 	 	 	 	 	 	 ddZd Z	ddZ
ddZedd	       Ze	 	 	 	 	 	 dd
       Zedd       Zy)
Middlewarea  Middleware object that is used to encapsulate middleware functions.

    This should generally not be instantiated directly, but rather through
    the `sanic.Sanic.middleware` decorator and its variants.

    Args:
        func (MiddlewareType): The middleware function to be called.
        location (MiddlewareLocation): The location of the middleware.
        priority (int): The priority of the middleware.
    intr   )funcprioritylocation
definitionc                j    || _         || _        || _        t        t        j
                        | _        y N)r   r   r   nextr   _counterr   )selfr   r   r   s       r   __init__zMiddleware.__init__!   s+     	  z223r   c                &     | j                   |i |S r   )r   )r!   argskwargss      r   __call__zMiddleware.__call__,   s    tyy$)&))r   c                ,    t        | j                        S r   )hashr   r!   s    r   __hash__zMiddleware.__hash__/   s    DIIr   c                    | j                   j                   d| j                  j                   d| j                   d| j                  j
                   dS )Nz(func=<function z>, priority=z, location=))	__class__r   r   r   r   namer)   s    r   __repr__zMiddleware.__repr__2   sV    ~~&&' ("ii001 2 '**+1.	
r   c                4    | j                   | j                   fS )zReturn a tuple of the priority and definition order.

        This is used to sort the middleware.

        Returns:
            tuple[int, int]: The priority and definition order.
        )r   r   r)   s    r   orderzMiddleware.order:   s     /00r   c                   t        |D cg c]'  }|D ]   }t        |t              r|nt        ||      " ) c}}      S c c}}w )ax  Convert middleware collections to a deque of Middleware objects.

        Args:
            *middleware_collections (Sequence[Union[Middleware, MiddlewareType]]):
                The middleware collections to convert.
            location (MiddlewareLocation): The location of the middleware.

        Returns:
            Deque[Middleware]: The converted middleware.
        )r   
isinstancer   )clsr   middleware_collections
collection
middlewares        r   convertzMiddleware.convertE   sb      
 #9	 ",
  j*5 
H566
 	
s   ,?
c                V    t               | _        t        | j                        | _         y)zReset the counter for the middleware definition order.

        This is used for testing.

        Returns:
            None
        N)r   r    r   )r4   s    r   reset_countzMiddleware.reset_count_   s     w&	r   N)r   )r   r   r   r   r   r   returnNone)r;   r   )r;   str)r;   ztuple[int, int])r5   z+Sequence[Union[Middleware, MiddlewareType]]r   r   r;   zDeque[Middleware])r;   r<   )r   r   r   __doc__r   r    __annotations__	__slots__r"   r&   r*   r/   propertyr1   classmethodr8   r:   r   r   r   r   r      s    	 wHJ>I 		4	4 %	4 		4
 
	4*
 1 1 
!L
 %
 
	
 
2 	' 	'r   r   N)
__future__r   collectionsr   enumr   r   	itertoolsr   typingr   r	   r
   sanic.models.handler_typesr   r   r   r   r   r   <module>rI      s2    "    ) ) 5 
Y' Y'r   