o
    ђh                     @  sF  d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
mZmZmZ d dlmZmZmZ d dlmZ d dlmZ d dlmZmZ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! d dl"m#Z#m$Z$m%Z% d dl&m'Z' d dl(m)Z) d dl*m+Z+ d dl,m-Z-m.Z.m/Z/ d dl0m1Z1m2Z2m3Z3m4Z4m5Z5 d dl6m7Z7m8Z8 G dd de9Z:G dd deZ;dLddZ<dMd d!Z=dNd#d$Z>dOd(d)Z?dPd0d1Z@eAd2ZBdQd4d5ZCG d6d7 d7ZDG d8d9 d9eDZEG d:d; d;eDZFG d<d= d=eDZGG d>d? d?eDZHed@ZIG dAdB dBeeI ZJdRdFdGZKG dHdI dIZLG dJdK dKZMdS )S    )annotationsN)	Awaitable
Collection	GeneratorSequence)AbstractAsyncContextManagerAbstractContextManagerasynccontextmanager)Enum)Pattern)AnyCallableTypeVar)wrap_app_handling_exceptions)get_route_pathis_async_callable)run_in_threadpool)CONVERTOR_TYPES	Convertor)URLHeadersURLPath)HTTPException)
Middleware)Request)PlainTextResponseRedirectResponseResponse)ASGIAppLifespanReceiveScopeSend)	WebSocketWebSocketClosec                      s"   e Zd ZdZd
 fdd	Z  ZS )NoMatchFoundz}
    Raised by `.url_for(name, **path_params)` and `.url_path_for(name, **path_params)`
    if no matching route exists.
    namestrpath_paramsdict[str, Any]returnNonec                   s0   d t| }t d| d| d d S )N, zNo route exists for name "z" and params "z".)joinlistkeyssuper__init__)selfr&   r(   params	__class__ J/var/www/html/govbot/env/lib/python3.10/site-packages/starlette/routing.pyr1   #   s   zNoMatchFound.__init__)r&   r'   r(   r)   r*   r+   )__name__
__module____qualname____doc__r1   __classcell__r6   r6   r4   r7   r%      s    r%   c                   @  s   e Zd ZdZdZdZdS )Matchr         N)r8   r9   r:   NONEPARTIALFULLr6   r6   r6   r7   r=   (   s    r=   objr   r*   boolc                 C  s4   t dt t| tjr| j} t| tjst| S )z~
    Correctly determines if an object is a coroutine function,
    including those wrapped in functools.partial objects.
    zViscoroutinefunction_or_partial is deprecated, and will be removed in a future release.)	warningswarnDeprecationWarning
isinstance	functoolspartialfuncinspectiscoroutinefunction)rC   r6   r6   r7   iscoroutinefunction_or_partial.   s   
rN   rK   3Callable[[Request], Awaitable[Response] | Response]r   c                   s*   t | r| ntt|  d fd	d
}|S )zi
    Takes a function or coroutine `func(request) -> response`,
    and returns an ASGI application.
    scoper!   receiver    sendr"   r*   r+   c                   s:   t | || d fd	d
}t| | ||I d H  d S )NrP   r!   rQ   r    rR   r"   r*   r+   c                   s&    I d H }|| ||I d H  d S Nr6   )rP   rQ   rR   response)frequestr6   r7   appJ   s   z*request_response.<locals>.app.<locals>.apprP   r!   rQ   r    rR   r"   r*   r+   )r   r   rP   rQ   rR   rW   rU   )rV   r7   rW   G   s   zrequest_response.<locals>.appNrX   )r   rI   rJ   r   rK   rW   r6   rZ   r7   request_response<   s   	r\   &Callable[[WebSocket], Awaitable[None]]c                   s   d fd	d
}|S )zM
    Takes a coroutine `func(session)`, and returns an ASGI application.
    rP   r!   rQ   r    rR   r"   r*   r+   c                   s<   t | ||d d fd
d}t| | ||I d H  d S )N)rQ   rR   rP   r!   rQ   r    rR   r"   r*   r+   c                   s    I d H  d S rS   r6   )rP   rQ   rR   )rK   sessionr6   r7   rW   ^   s   z+websocket_session.<locals>.app.<locals>.apprX   )r#   r   rY   rK   )r^   r7   rW   [   s   zwebsocket_session.<locals>.appNrX   r6   r[   r6   r_   r7   websocket_sessionS   s   r`   endpointCallable[..., Any]r'   c                 C  s   t | d| jjS )Nr8   )getattrr5   r8   )ra   r6   r6   r7   get_namef   s   rd   pathparam_convertorsdict[str, Convertor[Any]]r(   dict[str, str]tuple[str, dict[str, str]]c                 C  s^   t | D ]$\}}d| d | v r*|| }||}| d| d |} || q| |fS )N{})r.   items	to_stringreplacepop)re   rf   r(   keyvalue	convertorr6   r6   r7   replace_paramsj   s   

rs   z4{([a-zA-Z_][a-zA-Z0-9_]*)(:[a-zA-Z_][a-zA-Z0-9_]*)?}3tuple[Pattern[str], str, dict[str, Convertor[Any]]]c                 C  s  |  d }d}d}t }d}i }t| D ]X}|d\}}	|	d}	|	tv s0J d|	 dt|	 }
|t| ||	  7 }|d	| d
|
j
 d7 }|| ||	  7 }|d| 7 }||v rf|| |
||< | }q|rdt|}t|dkrdnd}td| d| d|  |r| |d dd }|t|d 7 }n|t| |d d 7 }|| |d 7 }t|||fS )a*  
    Given a path string, like: "/{username:str}",
    or a host string, like: "{subdomain}.mydomain.org", return a three-tuple
    of (regex, format, {param_name:convertor}).

    regex:      "/(?P<username>[^/]+)"
    format:     "/{username}"
    convertors: {"username": StringConvertor()}
    /^ r   r'   :zUnknown path convertor ''z(?P<>)z{%s}r,   r>   szDuplicated param name z	 at path N$)
startswithsetPARAM_REGEXfinditergroupslstripr   reescapestartregexaddendr-   sortedlen
ValueErrorsplitcompile)re   is_host
path_regexpath_formatduplicated_paramsidxrf   match
param_nameconvertor_typerr   namesendinghostnamer6   r6   r7   compile_path|   s:   


r   c                   @  s4   e Zd ZdddZdddZdddZdddZdS )	BaseRouterP   r!   r*   tuple[Match, Scope]c                 C     t  rS   NotImplementedError)r2   rP   r6   r6   r7   matches      zBaseRoute.matchesr&   r'   r(   r   r   c                K  r   rS   r   )r2   r&   r(   r6   r6   r7   url_path_for   r   zBaseRoute.url_path_forrQ   r    rR   r"   r+   c                   s   t  rS   r   r2   rP   rQ   rR   r6   r6   r7   handle   s   zBaseRoute.handlec                   s   |  |\}}|tjkr8|d dkr$tddd}||||I dH  dS |d dkr6t }||||I dH  dS || | |||I dH  dS )z
        A route may be used in isolation as a stand-alone ASGI app.
        This is a somewhat contrived case, as they'll almost always be used
        within a Router, but could be useful for some tooling and minimal apps.
        typehttp	Not Found  status_codeN	websocket)r   r=   r@   r   r$   updater   )r2   rP   rQ   rR   r   child_scoperT   websocket_closer6   r6   r7   __call__   s   

zBaseRoute.__call__NrP   r!   r*   r   r&   r'   r(   r   r*   r   rX   )r8   r9   r:   r   r   r   r   r6   r6   r6   r7   r      
    


r   c                   @  sT   e Zd Zdddddd)ddZd*ddZd+ddZd,d"d#Zd-d%d&Zd.d'd(ZdS )/RouteNT)methodsr&   include_in_schema
middlewarere   r'   ra   rb   r   Collection[str] | Noner&   
str | Noner   rD   r   Sequence[Middleware] | Noner*   r+   c                C  s  | ds	J d|| _|| _|d u rt|n|| _|| _|}t|tjr.|j	}t|tjs%t
|s8t
|rEt|| _|d u rDdg}n|| _|d urct|D ]\}}	}
|| jg|	R i |
| _qP|d u rkd | _ndd |D | _d| jv r~| jd t|\| _| _| _d S )Nru    Routed paths must start with '/'GETc                 S  s   h | ]}|  qS r6   )upper).0methodr6   r6   r7   	<setcomp>   s    z!Route.__init__.<locals>.<setcomp>HEAD)r   re   ra   rd   r&   r   rH   rI   rJ   rK   rL   
isfunctionismethodr\   rW   reversedr   r   r   r   r   rf   )r2   re   ra   r   r&   r   r   endpoint_handlerclsargskwargsr6   r6   r7   r1      s0   


zRoute.__init__rP   r!   r   c           	      C  s   |d dkrPt |}| j|}|rP| }| D ]\}}| j| |||< qt|di }|	| | j
|d}| jrK|d | jvrKtj|fS tj|fS tji fS )Nr   r   r(   ra   r(   r   )r   r   r   	groupdictrl   rf   convertdictgetr   ra   r   r=   rA   rB   r@   	r2   rP   
route_pathr   matched_paramsrp   rq   r(   r   r6   r6   r7   r      s   



zRoute.matchesr(   r   r   c                K  ^   t | }t | j }|| jks||krt||t| j| j|\}}|r)J t|ddS )Nr   re   protocolr   r/   rf   r&   r%   rs   r   r   r2   r&   r(   seen_paramsexpected_paramsre   remaining_paramsr6   r6   r7   r        
zRoute.url_path_forrQ   r    rR   r"   c                   sv   | j r/|d | j vr/dd| j i}d|v rtd|dtdd|d}||||I d H  d S | |||I d H  d S )Nr   Allowr,   rW   i  )r   headerszMethod Not Allowed)r   r-   r   r   rW   )r2   rP   rQ   rR   r   rT   r6   r6   r7   r     s   zRoute.handleotherc                 C  s.   t |to| j|jko| j|jko| j|jkS rS   )rH   r   re   ra   r   r2   r   r6   r6   r7   __eq__$  s   



zRoute.__eq__c                 C  s@   | j j}t| jp	g }| j| j}}| d|d|d|dS )N(path=, name=z
, methods=r{   )r5   r8   r   r   re   r&   )r2   
class_namer   re   r&   r6   r6   r7   __repr__,  s   zRoute.__repr__)re   r'   ra   rb   r   r   r&   r   r   rD   r   r   r*   r+   r   r   rX   r   r   r*   rD   r*   r'   	r8   r9   r:   r1   r   r   r   r   r   r6   r6   r6   r7   r      s    
)


r   c                   @  sP   e Zd Zdddd%ddZd&ddZd'ddZd(ddZd)d!d"Zd*d#d$ZdS )+WebSocketRouteN)r&   r   re   r'   ra   rb   r&   r   r   r   r*   r+   c          	      C  s   | ds	J d|| _|| _|d u rt|n|| _|}t|tjr+|j}t|tjs"t	
|s5t	|r;t|| _n|| _|d urYt|D ]\}}}|| jg|R i || _qFt|\| _| _| _d S )Nru   r   )r   re   ra   rd   r&   rH   rI   rJ   rK   rL   r   r   r`   rW   r   r   r   r   rf   )	r2   re   ra   r&   r   r   r   r   r   r6   r6   r7   r1   4  s   zWebSocketRoute.__init__rP   r!   r   c           	      C  s   |d dkrAt |}| j|}|rA| }| D ]\}}| j| |||< qt|di }|	| | j
|d}tj|fS tji fS )Nr   r   r(   r   )r   r   r   r   rl   rf   r   r   r   r   ra   r=   rB   r@   r   r6   r6   r7   r   Q  s   


zWebSocketRoute.matchesr(   r   r   c                K  r   )Nr   r   r   r   r6   r6   r7   r   `  r   zWebSocketRoute.url_path_forrQ   r    rR   r"   c                      |  |||I d H  d S rS   rW   r   r6   r6   r7   r   k     zWebSocketRoute.handler   rD   c                 C  "   t |to| j|jko| j|jkS rS   )rH   r   re   ra   r   r6   r6   r7   r   n     "zWebSocketRoute.__eq__c                 C  s   | j j d| jd| jdS )Nr   r   r{   )r5   r8   re   r&   r2   r6   r6   r7   r   q  s   zWebSocketRoute.__repr__)
re   r'   ra   rb   r&   r   r   r   r*   r+   r   r   rX   r   r   r   r6   r6   r6   r7   r   3  s    



r   c                   @  sd   e Zd Z			d*ddd+ddZed,ddZd-ddZd.ddZd/d"d#Zd0d&d'Z	d1d(d)Z
dS )2MountNr   re   r'   rW   ASGIApp | NoneroutesSequence[BaseRoute] | Noner&   r   r   r   r*   r+   c          	      C  s   |dks| dsJ d|d us|d usJ d|d| _|d ur'|| _nt|d| _| j| _|d urLt|D ]\}}}|| jg|R i || _q9|| _t| jd \| _	| _
| _d S )Nrw   ru   r   z0Either 'app=...', or 'routes=' must be specified)r   z/{path:path})r   rstripre   	_base_appRouterrW   r   r&   r   r   r   rf   )	r2   re   rW   r   r&   r   r   r   r   r6   r6   r7   r1   v  s   	zMount.__init__list[BaseRoute]c                 C     t | jdg S Nr   )rc   r   r   r6   r6   r7   r        zMount.routesrP   r!   r   c                 C  s   |d dv r_| dd}t|}| j|}|r_| }| D ]\}}| j| |||< q d|d }|d t	|  }	t
| di }
|
| |
| d|||	 | jd	}tj|fS tji fS )
Nr   r   r   	root_pathrw   ru   re   r(   app_root_path)r(   r   r   ra   )r   r   r   r   r   rl   rf   r   ro   r   r   r   rW   r=   rB   r@   )r2   rP   r   r   r   r   rp   rq   remaining_pathmatched_pathr(   r   r6   r6   r7   r     s&   



zMount.matchesr(   r   r   c          
   	   K  s(  | j d ur)|| j kr)d|v r)|d d|d< t| j| j|\}}|s(t|dS nf| j d u s6|| j d r| j d u r>|}n|t| j d d  }|d}d|d< t| j| j|\}}|d urd||d< | j	phg D ]%}z|j
|fi |}	t|dt|	 |	jdW   S  ty   Y qiw t||)Nre   ru   )re   rx   r>   rw   r   )r&   r   rs   r   rf   r   r   r   r   r   r   r   r'   r   r%   )
r2   r&   r(   re   r   remaining_name
path_kwargpath_prefixrouteurlr6   r6   r7   r     s.   


"
zMount.url_path_forrQ   r    rR   r"   c                   r   rS   r   r   r6   r6   r7   r     r   zMount.handler   rD   c                 C  r   rS   )rH   r   re   rW   r   r6   r6   r7   r     r   zMount.__eq__c                 C  2   | j j}| jpd}| d| jd|d| jdS )Nrw   r   r   , app=r{   )r5   r8   r&   re   rW   r2   r   r&   r6   r6   r7   r        
 zMount.__repr__)NNN)re   r'   rW   r   r   r   r&   r   r   r   r*   r+   r*   r   r   r   rX   r   r   r8   r9   r:   r1   propertyr   r   r   r   r   r   r6   r6   r6   r7   r   u  s    

!

r   c                   @  sX   e Zd Zd%d&d
dZed'ddZd(ddZd)ddZd*ddZd+d!d"Z	d,d#d$Z
dS )-HostNhostr'   rW   r   r&   r   r*   r+   c                 C  s<   | dr	J d|| _|| _|| _t|\| _| _| _d S )Nru   zHost must not start with '/')r   r  rW   r&   r   
host_regexhost_formatrf   )r2   r  rW   r&   r6   r6   r7   r1     s
   zHost.__init__r   c                 C  r   r   )rc   rW   r   r6   r6   r7   r     r   zHost.routesrP   r!   r   c           
      C  s   |d dv rMt |d}|dddd }| j|}|rM| }| D ]\}}| j| |||< q&t	|di }|
| || jd	}	tj|	fS tji fS )
Nr   r   rP   r  rw   rx   r   r(   )r(   ra   )r   r   r   r  r   r   rl   rf   r   r   r   rW   r=   rB   r@   )
r2   rP   r   r  r   r   rp   rq   r(   r   r6   r6   r7   r     s   



zHost.matchesr(   r   r   c          	   	   K  s   | j d ur&|| j kr&d|v r&|d}t| j| j|\}}|s%t||dS nQ| j d u s3|| j d rw| j d u r;|}n|t| j d d  }t| j| j|\}}| jpTg D ]!}z|j	|fi |}tt
||j|dW   S  tyv   Y qUw t||)Nre   )re   r  rx   r>   )re   r   r  )r&   ro   rs   r  rf   r   r   r   r   r   r'   r   r%   )	r2   r&   r(   re   r  r   r   r  r  r6   r6   r7   r     s&   


zHost.url_path_forrQ   r    rR   r"   c                   r   rS   r   r   r6   r6   r7   r     r   zHost.handler   rD   c                 C  r   rS   )rH   r
  r  rW   r   r6   r6   r7   r     r   zHost.__eq__c                 C  r  )Nrw   z(host=r   r  r{   )r5   r8   r&   r  rW   r  r6   r6   r7   r     r  zHost.__repr__rS   r  r'   rW   r   r&   r   r*   r+   r  r   r   rX   r   r   r  r6   r6   r6   r7   r
    s    



r
  _Tc                   @  s*   e Zd ZdddZdddZdddZdS )_AsyncLiftContextManagercmAbstractContextManager[_T]c                 C  
   || _ d S rS   )_cm)r2   r  r6   r6   r7   r1        
z!_AsyncLiftContextManager.__init__r*   r  c                   s   | j  S rS   )r  	__enter__r   r6   r6   r7   
__aenter__  s   
z#_AsyncLiftContextManager.__aenter__exc_typetype[BaseException] | None	exc_valueBaseException | None	tracebacktypes.TracebackType | Nonebool | Nonec                   s   | j |||S rS   )r  __exit__)r2   r  r  r  r6   r6   r7   	__aexit__!  s   z"_AsyncLiftContextManager.__aexit__N)r  r  )r*   r  )r  r  r  r  r  r  r*   r  )r8   r9   r:   r1   r  r!  r6   r6   r6   r7   r    s    

r  lifespan_context)Callable[[Any], Generator[Any, Any, Any]]1Callable[[Any], AbstractAsyncContextManager[Any]]c                   s&   t |  t d fdd}|S )NrW   r   r*   _AsyncLiftContextManager[Any]c                   s   t  | S rS   )r  r   cmgrr6   r7   wrapper/  s   z+_wrap_gen_lifespan_context.<locals>.wrapper)rW   r   r*   r%  )
contextlibcontextmanagerrI   wraps)r"  r(  r6   r&  r7   _wrap_gen_lifespan_context*  s   
r,  c                   @  s4   e Zd ZdddZdddZdddZdddZdS )_DefaultLifespanrouterr   c                 C  r  rS   )_router)r2   r.  r6   r6   r7   r1   7  r  z_DefaultLifespan.__init__r*   r+   c                      | j  I d H  d S rS   )r/  startupr   r6   r6   r7   r  :     z_DefaultLifespan.__aenter__exc_infoobjectc                   r0  rS   )r/  shutdown)r2   r3  r6   r6   r7   r!  =  r2  z_DefaultLifespan.__aexit__r2   r  rW   c                 C  s   | S rS   r6   )r2   rW   r6   r6   r7   r   @  s   z_DefaultLifespan.__call__N)r.  r   r*   r+   )r3  r4  r*   r+   )r2   r  rW   r4  r*   r  )r8   r9   r:   r1   r  r!  r   r6   r6   r6   r7   r-  6  r   r-  c                   @  s   e Zd Z						dPdddQddZdRddZdSd"d#ZdTd$d%ZdTd&d'ZdRd(d)ZdRd*d+Z	dRd,d-Z
dUd/d0ZdVdWd5d6ZdVdXd8d9Z			dYdZd?d@Z	dVd[dBdCZ			dYd\dEdFZdVd]dGdHZd^dLdMZd_dNdOZdS )`r   NTr   r   r   redirect_slashesrD   defaultr   
on_startup"Sequence[Callable[[], Any]] | Noneon_shutdownlifespanLifespan[Any] | Noner   r   r*   r+   c                C  s  |d u rg nt || _|| _|d u r| jn|| _|d u rg nt || _|d u r)g nt || _|s2|r?tdt	 |r?td |d u rIt
| | _n%t|rZtdt	 t|| _nt|rktdt	 t|| _n|| _| j| _|rt|D ]\}}	}
|| jg|	R i |
| _qxd S d S )NzThe on_startup and on_shutdown parameters are deprecated, and they will be removed on version 1.0. Use the lifespan parameter instead. See more about it on https://www.starlette.io/lifespan/.zThe `lifespan` parameter cannot be used with `on_startup` or `on_shutdown`. Both `on_startup` and `on_shutdown` will be ignored.zjasync generator function lifespans are deprecated, use an @contextlib.asynccontextmanager function insteadzdgenerator function lifespans are deprecated, use an @contextlib.asynccontextmanager function instead)r.   r   r7  	not_foundr8  r9  r;  rE   rF   rG   r-  r"  rL   isasyncgenfunctionr	   isgeneratorfunctionr,  rW   middleware_stackr   )r2   r   r7  r8  r9  r;  r<  r   r   r   r   r6   r6   r7   r1   E  sN   

zRouter.__init__rP   r!   rQ   r    rR   r"   c                   s^   |d dkrt  }||||I d H  d S d|v rtddtddd}||||I d H  d S )Nr   r   rW   r   r   r   )r$   r   r   )r2   rP   rQ   rR   r   rT   r6   r6   r7   r>    s   
zRouter.not_foundr&   r'   r(   r   r   c             	   K  s@   | j D ]}z|j|fi |W   S  ty   Y qw t||rS   )r   r   r%   )r2   r&   r(   r  r6   r6   r7   r     s   

zRouter.url_path_forc                   .   | j D ]}t|r| I dH  q|  qdS )z7
        Run any `.on_startup` event handlers.
        N)r9  r   r2   handlerr6   r6   r7   r1       
zRouter.startupc                   rB  )z8
        Run any `.on_shutdown` event handlers.
        N)r;  r   rC  r6   r6   r7   r5    rE  zRouter.shutdownc              	     s  d}| d}| I dH  zE| |4 I dH /}|dur,d|vr%td|d | |ddiI dH  d}| I dH  W d  I dH  n1 I dH sMw   Y  W n# tyv   t }|rk|d	|d
I dH   |d|d
I dH   w |ddiI dH  dS )z{
        Handle ASGI lifespan messages, which allows us to manage application
        startup and shutdown events.
        FrW   Nstatez:The server does not support "state" in the lifespan scope.r   zlifespan.startup.completeTzlifespan.shutdown.failed)r   messagezlifespan.startup.failedzlifespan.shutdown.complete)r   r"  RuntimeErrorr   BaseExceptionr  
format_exc)r2   rP   rQ   rR   startedrW   maybe_stateexc_textr6   r6   r7   r<    s0   
(zRouter.lifespanc                   s   |  |||I dH  dS )z;
        The main entry point to the Router class.
        N)rA  r   r6   r6   r7   r     s   zRouter.__call__c                   s  |d dv s	J d|vr| |d< |d dkr#|  |||I d H  d S d }| jD ]-}||\}}|tjkrH|| ||||I d H   d S |tjkrU|d u rU|}|}q(|d urk|| ||||I d H  d S t|}	|d dkr| j	r|	dkrt
|}
|	dr|
d d|
d< n|
d d |
d< | jD ]&}||
\}}|tjkrt|
d}tt|d	}||||I d H   d S q| |||I d H  d S )
Nr   )r   r   r<  r.  r<  r   ru   re   r  )r  )r<  r   r   r=   rB   r   r   rA   r   r7  r   endswithr   r@   r   r   r'   r8  )r2   rP   rQ   rR   rJ   r  r   r   partial_scoper   redirect_scoperedirect_urlrT   r6   r6   r7   rW     sJ   







z
Router.appr   c                 C  s   t |to
| j|jkS rS   )rH   r   r   r   r6   r6   r7   r      s   zRouter.__eq__re   rW   r   r   c                 C     t |||d}| j| d S N)rW   r&   )r   r   append)r2   re   rW   r&   r  r6   r6   r7   mount     zRouter.mountr  c                 C  rR  rS  )r
  r   rT  )r2   r  rW   r&   r  r6   r6   r7   r    rV  zRouter.hostra   rO   r   r   r   c                 C  s"   t |||||d}| j| d S )N)ra   r   r&   r   )r   r   rT  )r2   re   ra   r   r&   r   r  r6   r6   r7   	add_route  s   zRouter.add_router]   c                 C  rR  )N)ra   r&   )r   r   rT  )r2   re   ra   r&   r  r6   r6   r7   add_websocket_route  s   zRouter.add_websocket_router   c                   s&   t dt d fdd}|S )	z
        We no longer document this decorator style API, and its usage is discouraged.
        Instead you should use the following approach:

        >>> routes = [Route(path, endpoint=...), ...]
        >>> app = Starlette(routes=routes)
        zThe `route` decorator is deprecated, and will be removed in version 1.0.0.Refer to https://www.starlette.io/routing/#http-routing for the recommended approach.rK   r   r*   c                   s   j |  d | S )N)r   r&   r   )rW  r_   r   r   r&   re   r2   r6   r7   	decorator9  s   zRouter.route.<locals>.decoratorNrK   r   r*   r   rE   rF   rG   )r2   re   r   r&   r   rZ  r6   rY  r7   r  %  s   
zRouter.routec                   s"   t dt d fdd}|S )	a  
        We no longer document this decorator style API, and its usage is discouraged.
        Instead you should use the following approach:

        >>> routes = [WebSocketRoute(path, endpoint=...), ...]
        >>> app = Starlette(routes=routes)
        zThe `websocket_route` decorator is deprecated, and will be removed in version 1.0.0. Refer to https://www.starlette.io/routing/#websocket-routing for the recommended approach.rK   r   r*   c                   s   j |  d | S )N)r&   )rX  r_   r&   re   r2   r6   r7   rZ  S  s   z)Router.websocket_route.<locals>.decoratorNr[  r\  )r2   re   r&   rZ  r6   r]  r7   websocket_routeE  s   zRouter.websocket_route
event_typerK   Callable[[], Any]c                 C  s4   |dv sJ |dkr| j | d S | j| d S )N)r1  r5  r1  )r9  rT  r;  )r2   r_  rK   r6   r6   r7   add_event_handlerY  s   zRouter.add_event_handlerc                   s    t dt d fdd}|S )NzThe `on_event` decorator is deprecated, and will be removed in version 1.0.0. Refer to https://www.starlette.io/lifespan/ for recommended approach.rK   r   r*   c                   s     |  | S rS   )ra  r_   r_  r2   r6   r7   rZ  h  s   z"Router.on_event.<locals>.decoratorr[  r\  )r2   r_  rZ  r6   rb  r7   on_eventa  s   zRouter.on_event)NTNNNN)r   r   r7  rD   r8  r   r9  r:  r;  r:  r<  r=  r   r   r*   r+   rX   r   r6  r   rS   )re   r'   rW   r   r&   r   r*   r+   r  )NNT)re   r'   ra   rO   r   r   r&   r   r   rD   r*   r+   )re   r'   ra   r]   r&   r   r*   r+   )
re   r'   r   r   r&   r   r   rD   r*   r   )re   r'   r&   r   r*   r   )r_  r'   rK   r`  r*   r+   )r_  r'   r*   r   )r8   r9   r:   r1   r>  r   r1  r5  r<  r   rW   r   rU  r  rW  rX  r  r^  ra  rc  r6   r6   r6   r7   r   D  sB    
=








2 
r   )rC   r   r*   rD   )rK   rO   r*   r   )rK   r]   r*   r   )ra   rb   r*   r'   )re   r'   rf   rg   r(   rh   r*   ri   )re   r'   r*   rt   )r"  r#  r*   r$  )N
__future__r   r)  rI   rL   r   r  typesrE   collections.abcr   r   r   r   r   r   r	   enumr
   r   typingr   r   r   starlette._exception_handlerr   starlette._utilsr   r   starlette.concurrencyr   starlette.convertorsr   r   starlette.datastructuresr   r   r   starlette.exceptionsr   starlette.middlewarer   starlette.requestsr   starlette.responsesr   r   r   starlette.typesr   r   r    r!   r"   starlette.websocketsr#   r$   	Exceptionr%   r=   rN   r\   r`   rd   rs   r   r   r   r   r   r   r   r
  r  r  r,  r-  r   r6   r6   r6   r7   <module>   sV    






8aBd>
