a
    ^g	                     @  s@  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	Z	d dlm
Z
 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 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l%m&Z&m'Z'm(Z(m)Z)m*Z* d dl+m,Z,m-Z- G dd de.Z/G dd deZ0dddddZ1dddddZ2ddddd Z3d!d"d#d$d%Z4d"d&d'd(d)d*d+Z5e6d,Z7d"d-d.d/d0Z8G d1d2 d2Z9G d3d4 d4e9Z:G d5d6 d6e9Z;G d7d8 d8e9Z<G d9d: d:e9Z=e>d;Z?G d<d= d=ej@e? ZAd>d?d@dAdBZBG dCdD dDZCG dEdF dFZDdS )G    )annotationsN)asynccontextmanager)Enum)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dd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.
    strzdict[str, typing.Any]Nonenamepath_paramsreturnc                   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__ _/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/starlette/routing.pyr'   !   s    zNoMatchFound.__init__)__name__
__module____qualname____doc__r'   __classcell__r,   r,   r*   r-   r      s   r   c                   @  s   e Zd ZdZdZdZdS )Matchr         N)r.   r/   r0   NONEPARTIALFULLr,   r,   r,   r-   r3   &   s   r3   
typing.Anybool)objr!   c                 C  s*   t dt t| tjr | j} q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)r;   r,   r,   r-   iscoroutinefunction_or_partial,   s    rE   Atyping.Callable[[Request], typing.Awaitable[Response] | Response]r   rB   r!   c                   s4   t | r| n
tt|  ddddd fdd}|S )zi
    Takes a function or coroutine `func(request) -> response`,
    and returns an ASGI application.
    r   r   r   r   scopereceivesendr!   c                   sB   t | || ddddd fdd}t| | ||I d H  d S )Nr   r   r   r   rH   c                   s$    I d H }|| ||I d H  d S Nr,   )rI   rJ   rK   response)frequestr,   r-   appH   s    z*request_response.<locals>.app.<locals>.app)r   r   rI   rJ   rK   rP   rN   )rO   r-   rP   E   s    zrequest_response.<locals>.app)r   r@   rA   r   rB   rP   r,   rR   r-   request_response:   s    	rT   4typing.Callable[[WebSocket], typing.Awaitable[None]]c                   s   ddddd fdd}|S )zM
    Takes a coroutine `func(session)`, and returns an ASGI application.
    r   r   r   r   rH   c                   sD   t | ||d ddddd fdd}t| | ||I d H  d S )	N)rJ   rK   r   r   r   r   rH   c                   s    I d H  d S rL   r,   )rI   rJ   rK   )rB   sessionr,   r-   rP   \   s    z+websocket_session.<locals>.app.<locals>.app)r   r   rQ   rB   )rV   r-   rP   Y   s    zwebsocket_session.<locals>.appr,   rS   r,   rW   r-   websocket_sessionQ   s    rX    typing.Callable[..., typing.Any]r   )endpointr!   c                 C  s   t | d| jjS )Nr.   )getattrr+   r.   )rZ   r,   r,   r-   get_named   s    r\   z dict[str, Convertor[typing.Any]]zdict[str, str]ztuple[str, dict[str, str]])pathparam_convertorsr    r!   c                 C  s^   t | D ]H\}}d| d | v r|| }||}| d| d |} || q| |fS )N{})r$   itemsZ	to_stringreplacepop)r]   r^   r    keyvalue	convertorr,   r,   r-   replace_paramsh   s    
rg   z4{([a-zA-Z_][a-zA-Z0-9_]*)(:[a-zA-Z_][a-zA-Z0-9_]*)?}zAtuple[typing.Pattern[str], str, dict[str, Convertor[typing.Any]]])r]   r!   c                 C  s  |  d }d}d}t }d}i }t| D ]}|d\}}	|	d}	|	tv s`J d|	 dt|	 }
|t| ||	  7 }|d	| d
|
j
 d7 }|| ||	  7 }|d| 7 }||v r|| |
||< | }q,|r"dt|}t|dkrdnd}td| d| d|  |rR| |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"   r4   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)r]   Zis_host
path_regexpath_formatZduplicated_paramsidxr^   match
param_nameZconvertor_typerf   namesendinghostnamer,   r,   r-   compile_pathz   s:    


r   c                   @  sV   e Zd ZdddddZdddd	d
dZdddddddZdddddddZdS )	BaseRouter   tuple[Match, Scope]rI   r!   c                 C  s
   t  d S rL   NotImplementedError)r(   rI   r,   r,   r-   matches   s    zBaseRoute.matchesr   r9   r   r   c                K  s
   t  d S rL   r   )r(   r   r    r,   r,   r-   url_path_for   s    zBaseRoute.url_path_forr   r   r   rH   c                   s
   t  d S rL   r   r(   rI   rJ   rK   r,   r,   r-   handle   s    zBaseRoute.handlec                   s   |  |\}}|tjkrl|d dkrDtddd}||||I dH  n$|d dkrht }||||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   r3   r6   r   r   updater   )r(   rI   rJ   rK   r   child_scoperM   websocket_closer,   r,   r-   __call__   s    

zBaseRoute.__call__N)r.   r/   r0   r   r   r   r   r,   r,   r,   r-   r      s   r   c                	   @  s   e Zd Zddddddddddd	d
dddZdddddZddddddZdddd
dddZdddddZdd d!d"ZdS )#RouteNT)methodsr   include_in_schema
middlewarer   rY   list[str] | None
str | Noner:   "typing.Sequence[Middleware] | Noner   )r]   rZ   r   r   r   r   r!   c                C  s
  | dsJ d|| _|| _|d u r.t|n|| _|| _|}t|tjrR|j	}q>t
|sft
|rt|| _|d u rdg}n|| _|d urt|D ]$\}}	}
|| jg|	R i |
| _q|d u rd | _n&dd |D | _d| jv r| jd t|\| _| _| _d S )Nrh    Routed paths must start with '/'GETc                 S  s   h | ]}|  qS r,   )upper).0methodr,   r,   r-   	<setcomp>       z!Route.__init__.<locals>.<setcomp>HEAD)rr   r]   rZ   r\   r   r   r?   r@   rA   rB   rC   
isfunctionismethodrT   rP   reversedr   r|   r   r   r   r^   )r(   r]   rZ   r   r   r   r   endpoint_handlerclsargskwargsr,   r,   r-   r'      s,    


zRoute.__init__r   r   r   c           	      C  s   |d dkrt |}| j|}|r| }| D ]\}}| j| |||< q4t|di }|	| | j
|d}| jr|d | jvrtj|fS tj|fS tji fS )Nr   r   r    rZ   r    r   )r   r   r   	groupdictra   r^   convertdictgetr   rZ   r   r3   r7   r8   r6   	r(   rI   
route_pathr   matched_paramsrd   re   r    r   r,   r,   r-   r      s    


zRoute.matchesr9   r   r   c                K  s^   t | }t | j }|| jks,||kr6t||t| j| j|\}}|rRJ t|ddS )Nr   r]   protocolrs   r%   r^   r   r   rg   r   r   r(   r   r    Zseen_paramsZexpected_paramsr]   remaining_paramsr,   r,   r-   r     s    
zRoute.url_path_forr   r   rH   c                   st   | j r\|d | j vr\dd| j i}d|v r:td|dntdd|d}||||I d H  n| |||I d H  d S )Nr   ZAllowr"   rP   i  )r   headerszMethod Not Allowed)r   r#   r   r   rP   )r(   rI   rJ   rK   r   rM   r,   r,   r-   r     s    zRoute.handleotherr!   c                 C  s.   t |to,| j|jko,| j|jko,| j|jkS rL   )r?   r   r]   rZ   r   r(   r   r,   r,   r-   __eq__"  s    



zRoute.__eq__r!   c                 C  s@   | j j}t| jpg }| j| j }}| d|d|d|dS )N(path=, name=z
, methods=rn   )r+   r.   r~   r   r]   r   )r(   
class_namer   r]   r   r,   r,   r-   __repr__*  s    zRoute.__repr__	r.   r/   r0   r'   r   r   r   r   r   r,   r,   r,   r-   r      s   )r   c                   @  s~   e Zd Zdddddddddd	d
ZdddddZddddddZdddddddZdddddZdddd ZdS )!WebSocketRouteN)r   r   r   rY   r   r   r   )r]   rZ   r   r   r!   c          	      C  s   | dsJ d|| _|| _|d u r.t|n|| _|}t|tjrL|j}q8t	
|s`t	|rlt|| _n|| _|d urt|D ]$\}}}|| jg|R i || _qt|\| _| _| _d S )Nrh   r   )rr   r]   rZ   r\   r   r?   r@   rA   rB   rC   r   r   rX   rP   r   r   r   r   r^   )	r(   r]   rZ   r   r   r   r   r   r   r,   r,   r-   r'   2  s    zWebSocketRoute.__init__r   r   r   c           	      C  s   |d dkrt |}| j|}|r| }| D ]\}}| j| |||< q4t|di }|	| | j
|d}tj|fS tji fS )Nr   r   r    r   )r   r   r   r   ra   r^   r   r   r   r   rZ   r3   r8   r6   r   r,   r,   r-   r   O  s    

zWebSocketRoute.matchesr9   r   r   c                K  s^   t | }t | j }|| jks,||kr6t||t| j| j|\}}|rRJ t|ddS )Nr   r   r   r   r,   r,   r-   r   ^  s    
zWebSocketRoute.url_path_forr   r   rH   c                   s   |  |||I d H  d S rL   rP   r   r,   r,   r-   r   i  s    zWebSocketRoute.handler:   r   c                 C  s"   t |to | j|jko | j|jkS rL   )r?   r   r]   rZ   r   r,   r,   r-   r   l  s    zWebSocketRoute.__eq__r   c                 C  s   | j j d| jd| jdS )Nr   r   rn   )r+   r.   r]   r   r(   r,   r,   r-   r   o  s    zWebSocketRoute.__repr__r   r,   r,   r,   r-   r   1  s   r   c                	   @  s   e Zd Zd%ddddddddd	d
dZeddddZdddddZddddddZdddddddZddd d!d"Z	ddd#d$Z
dS )&MountNr   r   ASGIApp | None!typing.Sequence[BaseRoute] | Noner   r   r   )r]   rP   routesr   r   r!   c          	      C  s   |dks| dsJ d|d us2|d us2J d|d| _|d urN|| _nt|d| _| j| _|d urt|D ]$\}}}|| jg|R i || _qr|| _t| jd \| _	| _
| _d S )Nrj   rh   r   z0Either 'app=...', or 'routes=' must be specified)r   z/{path:path})rr   rstripr]   	_base_appRouterrP   r   r   r   r   r   r^   )	r(   r]   rP   r   r   r   r   r   r   r,   r,   r-   r'   t  s    	zMount.__init__list[BaseRoute]r   c                 C  s   t | jdg S Nr   )r[   r   r   r,   r,   r-   r     s    zMount.routesr   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_pathrj   rh   r]   r    app_root_path)r    r   r   rZ   )r   r   r   r   r   ra   r^   r   rc   r   r   r   rP   r3   r8   r6   )r(   rI   r   r   r   r   rd   re   Zremaining_pathZmatched_pathr    r   r,   r,   r-   r     s&    


zMount.matchesr9   r   r   c          
   	   K  s2  | j d urR|| j krRd|v rR|d d|d< t| j| j|\}}|sPt|dS n| j d u sn|| j d r$| j d u r~|}n|t| j d d  }|d}d|d< t| j| j|\}}|d ur||d< | j	pg D ]N}z4|j
|fi |}	t|dt|	 |	jdW   S  ty    Y q0 qt||d S )Nr]   rh   )r]   rk   r4   rj   r   )r   rw   rg   r   r^   r   rr   r   r   r   r   r   r   r   r   )
r(   r   r    r]   r   remaining_nameZ
path_kwargZpath_prefixrouteurlr,   r,   r-   r     s*    

"zMount.url_path_forr   r   rH   c                   s   |  |||I d H  d S rL   r   r   r,   r,   r-   r     s    zMount.handler:   r   c                 C  s"   t |to | j|jko | j|jkS rL   )r?   r   r]   rP   r   r,   r,   r-   r     s    zMount.__eq__c                 C  s2   | j j}| jpd}| d| jd|d| jdS )Nrj   r   r   , app=rn   )r+   r.   r   r]   rP   r(   r   r   r,   r,   r-   r     s    
zMount.__repr__)NNNr.   r/   r0   r'   propertyr   r   r   r   r   r   r,   r,   r,   r-   r   s  s      !r   c                   @  s   e Zd Zd"dddddddZed	d
ddZdddddZddddddZdddddddZdddddZ	dd
d d!Z
dS )#HostNr   r   r   r   hostrP   r   r!   c                 C  s<   | drJ d|| _|| _|| _t|\| _| _| _d S )Nrh   zHost must not start with '/')rr   r   rP   r   r   
host_regexhost_formatr^   )r(   r   rP   r   r,   r,   r-   r'     s
    zHost.__init__r   r   c                 C  s   t | jdg S r   )r[   rP   r   r,   r,   r-   r     s    zHost.routesr   r   r   c           
      C  s   |d dv rt |d}|dddd }| j|}|r| }| D ]\}}| j| |||< qLt	|di }|
| || jd	}	tj|	fS tji fS )
Nr   r   rI   r   rj   rk   r   r    )r    rZ   )r   r   r   r   r   r   ra   r^   r   r   r   rP   r3   r8   r6   )
r(   rI   r   r   r   r   rd   re   r    r   r,   r,   r-   r     s    


zHost.matchesr9   r   r   c          	   	   K  s   | j d urL|| j krLd|v rL|d}t| j| j|\}}|st||dS n| j d u sf|| j d r| j d u rv|}n|t| j d d  }t| j| j|\}}| jpg D ]D}z,|j	|fi |}tt
||j|dW   S  ty   Y q0 qt||d S )Nr]   )r]   r   rk   r4   )r]   r   r   )r   rc   rg   r   r^   r   rr   r   r   r   r   r   r   )	r(   r   r    r]   r   r   r   r   r   r,   r,   r-   r     s"    

zHost.url_path_forr   r   rH   c                   s   |  |||I d H  d S rL   r   r   r,   r,   r-   r   	  s    zHost.handler:   r   c                 C  s"   t |to | j|jko | j|jkS rL   )r?   r   r   rP   r   r,   r,   r-   r     s    zHost.__eq__c                 C  s2   | j j}| jpd}| d| jd|d| jdS )Nrj   z(host=r   r   rn   )r+   r.   r   r   rP   r   r,   r,   r-   r     s    
zHost.__repr__)Nr   r,   r,   r,   r-   r     s   r   _Tc                   @  s<   e Zd ZddddZddddZd	d
dddddZdS )_AsyncLiftContextManagerztyping.ContextManager[_T])cmc                 C  s
   || _ d S rL   )_cm)r(   r   r,   r,   r-   r'     s    z!_AsyncLiftContextManager.__init__r   r   c                   s
   | j  S rL   )r   	__enter__r   r,   r,   r-   
__aenter__  s    z#_AsyncLiftContextManager.__aenter__ztype[BaseException] | NonezBaseException | Noneztypes.TracebackType | Nonezbool | None)exc_type	exc_value	tracebackr!   c                   s   | j |||S rL   )r   __exit__)r(   r   r   r   r,   r,   r-   	__aexit__  s    z"_AsyncLiftContextManager.__aexit__N)r.   r/   r0   r'   r   r   r,   r,   r,   r-   r     s   r   zStyping.Callable[[typing.Any], typing.Generator[typing.Any, typing.Any, typing.Any]]zEtyping.Callable[[typing.Any], typing.AsyncContextManager[typing.Any]])lifespan_contextr!   c                   s,   t |  t ddd fdd}|S )Nr9   z$_AsyncLiftContextManager[typing.Any])rP   r!   c                   s   t  | S rL   )r   r   Zcmgrr,   r-   wrapper-  s    z+_wrap_gen_lifespan_context.<locals>.wrapper)
contextlibcontextmanagerr@   wraps)r   r   r,   r   r-   _wrap_gen_lifespan_context(  s    
r   c                   @  sJ   e Zd ZddddZddddZd	dd
ddZdd	ddddZdS )_DefaultLifespanr   )routerc                 C  s
   || _ d S rL   )_router)r(   r   r,   r,   r-   r'   5  s    z_DefaultLifespan.__init__r   r   c                   s   | j  I d H  d S rL   )r   startupr   r,   r,   r-   r   8  s    z_DefaultLifespan.__aenter__object)exc_infor!   c                   s   | j  I d H  d S rL   )r   shutdown)r(   r  r,   r,   r-   r   ;  s    z_DefaultLifespan.__aexit__r   )r(   rP   r!   c                 C  s   | S rL   r,   )r(   rP   r,   r,   r-   r   >  s    z_DefaultLifespan.__call__N)r.   r/   r0   r'   r   r   r   r,   r,   r,   r-   r   4  s   r   c                   @  sh  e Zd ZdGddddddddd	d
dddZdddd
dddZddddddZd
dddZd
dddZdddd
ddd Zdddd
dd!d"Z	dddd
dd#d$Z
ddd%d&d'ZdHdd(d)d
d*d+d,ZdIdd(d)d
d-d.d/ZdJdd0d1d)dd
d2d3d4ZdKdd5d)d
d6d7d8ZdLdd1d)dd9d:d;d<ZdMdd)d9d=d>d?Zdd@d
dAdBdCZdd9dDdEdFZdS )Nr   NTr   r   r:   r   z7typing.Sequence[typing.Callable[[], typing.Any]] | NonezLifespan[typing.Any] | Noner   r   )r   redirect_slashesdefault
on_startupon_shutdownlifespanr   r!   c                C  s  |d u rg nt || _|| _|d u r*| jn|| _|d u r<g nt || _|d u rRg nt || _|sd|r~tdt	 |r~td |d u rt
| | _nJt|rtdt	 t|| _n(t|rtdt	 t|| _n|| _| j| _|rt|D ]$\}}	}
|| jg|	R i |
| _qd 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   r  	not_foundr  r  r  r<   r=   r>   r   r   rC   isasyncgenfunctionr   isgeneratorfunctionr   rP   middleware_stackr   )r(   r   r  r  r  r  r  r   r   r   r   r,   r,   r-   r'   C  sJ    

zRouter.__init__r   r   r   rH   c                   s^   |d dkr(t  }||||I d H  d S d|v r<tddntddd}||||I d H  d S )Nr   r   rP   r   r   r   )r   r   r   )r(   rI   rJ   rK   r   rM   r,   r,   r-   r	    s    zRouter.not_foundr   r9   r   r   c             	   K  sF   | j D ]0}z|j|fi |W   S  ty4   Y q0 qt||d S rL   )r   r   r   )r(   r   r    r   r,   r,   r-   r     s    
zRouter.url_path_forr   c                   s,   | j D ] }t|r | I dH  q|  qdS )z7
        Run any `.on_startup` event handlers.
        N)r  r   r(   handlerr,   r,   r-   r     s    
zRouter.startupc                   s,   | j D ] }t|r | I dH  q|  qdS )z8
        Run any `.on_shutdown` event handlers.
        N)r  r   r  r,   r,   r-   r    s    
zRouter.shutdownc              	     s  d}| d}| I dH  z| |4 I dH ^}|durVd|vrHtd|d | |ddiI dH  d}| I dH  W d  I dH  q1 I dH s0    Y  W nJ ty   t }|r|d	|d
I dH  n|d|d
I dH   Y n0 |ddiI dH  dS )z{
        Handle ASGI lifespan messages, which allows us to manage application
        startup and shutdown events.
        FrP   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)r(   rI   rJ   rK   startedrP   Zmaybe_stateexc_textr,   r,   r-   r    s&    
:zRouter.lifespanc                   s   |  |||I dH  dS )z;
        The main entry point to the Router class.
        N)r  r   r,   r,   r-   r     s    zRouter.__call__c                   s  |d dv sJ d|vr | |d< |d dkrD|  |||I d H  d S d }| jD ]Z}||\}}|tjkr|| ||||I d H   d S |tjkrN|d u rN|}|}qN|d ur|| ||||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 ]P}||
\}}|tjkr:t|
d}tt|d	}||||I d H   d S q:| |||I d H  d S )
Nr   )r   r   r  r   r  r   rh   r]   r   )r   )r  r   r   r3   r8   r   r   r7   r   r  r   endswithr   r6   r   r   r   r  )r(   rI   rJ   rK   rA   r   r   r   Zpartial_scoper   Zredirect_scopeZredirect_urlrM   r,   r,   r-   rP     sD    



 


z
Router.appr   c                 C  s   t |to| j|jkS rL   )r?   r   r   r   r,   r,   r-   r     s    zRouter.__eq__r   r   )r]   rP   r   r!   c                 C  s   t |||d}| j| d S N)rP   r   )r   r   append)r(   r]   rP   r   r   r,   r,   r-   mount  s    zRouter.mountr   c                 C  s   t |||d}| j| d S r  )r   r   r  )r(   r   rP   r   r   r,   r,   r-   r     s    zRouter.hostrF   r   )r]   rZ   r   r   r   r!   c                 C  s"   t |||||d}| j| d S )N)rZ   r   r   r   )r   r   r  )r(   r]   rZ   r   r   r   r   r,   r,   r-   	add_route
  s    zRouter.add_routerU   )r]   rZ   r   r!   c                 C  s   t |||d}| j| d S )N)rZ   r   )r   r   r  )r(   r]   rZ   r   r   r,   r,   r-   add_websocket_route  s    zRouter.add_websocket_routetyping.Callable)r]   r   r   r   r!   c                   s,   t dt dd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.r  rG   c                   s   j |  d | S )N)r   r   r   )r  rW   r   r   r   r]   r(   r,   r-   	decorator8  s    zRouter.route.<locals>.decoratorr<   r=   r>   )r(   r]   r   r   r   r  r,   r  r-   r   $  s    
zRouter.route)r]   r   r!   c                   s(   t dt dd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.r  rG   c                   s   j |  d | S )N)r   )r  rW   r   r]   r(   r,   r-   r  R  s    z)Router.websocket_route.<locals>.decoratorr  )r(   r]   r   r  r,   r   r-   websocket_routeD  s    zRouter.websocket_routeztyping.Callable[[], typing.Any])
event_typerB   r!   c                 C  s2   |dv sJ |dkr"| j | n| j| d S )N)r   r  r   )r  r  r  )r(   r"  rB   r,   r,   r-   add_event_handlerX  s    zRouter.add_event_handler)r"  r!   c                   s&   t dt dd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.r  rG   c                   s     |  | S rL   )r#  rW   r"  r(   r,   r-   r  g  s    z"Router.on_event.<locals>.decoratorr  )r(   r"  r  r,   r$  r-   on_event`  s    zRouter.on_event)NTNNNN)N)N)NNT)N)NNT)N)r.   r/   r0   r'   r	  r   r   r  r  r   rP   r   r  r   r  r  r   r!  r#  r%  r,   r,   r,   r-   r   B  s@          >

2        r   )E
__future__r   r   r@   rC   rx   r   typestypingr<   r   enumr   Zstarlette._exception_handlerr   Zstarlette._utilsr   r   Zstarlette.concurrencyr   Zstarlette.convertorsr	   r
   Zstarlette.datastructuresr   r   r   Zstarlette.exceptionsr   Zstarlette.middlewarer   Zstarlette.requestsr   Zstarlette.responsesr   r   r   Zstarlette.typesr   r   r   r   r   Zstarlette.websocketsr   r   	Exceptionr   r3   rE   rT   rX   r\   rg   r   rt   r   r   r   r   r   r   TypeVarr   AsyncContextManagerr   r   r   r   r,   r,   r,   r-   <module>   sP   
8aBd>
