ó
    öÞ j`  ã                  óR  • S SK Jr  S SKrS SKrS SKrS SKJrJ	r	J
r
Jr  SSKJrJr  SSKJrJrJr  / SQr S S	KJr  S S
KJrJr  SSSS.             SS jjr S       SS jjr " S S5      rg! \ a*    SSSS.             SS jjr S       SS jjr N:f = f)é    )ÚannotationsN)ÚAnyÚ	AwaitableÚCallableÚLiteralé   )ÚRequestÚResponseé   )ÚServerÚServerConnectionÚserve)ÚrouteÚ
unix_routeÚRouter)ÚNotFound)ÚMapÚRequestRedirect)Úserver_nameÚsslÚcreate_routerc               óè   ^^	• Uc  SOSnUSLa  Ub  X%S'   Uc  [         nU" XU5      m	UR                  SS5      mTc  T	R                  nO      SUU	4S jjn[        T	R                  /UQ7SU0UD6$ )	ax  
Create a WebSocket server dispatching connections to different handlers.

This feature requires the third-party library `werkzeug`_:

.. code-block:: console

    $ pip install werkzeug

.. _werkzeug: https://werkzeug.palletsprojects.com/

:func:`route` accepts the same arguments as
:func:`~websockets.sync.server.serve`, except as described below.

The first argument is a :class:`werkzeug.routing.Map` that maps URL patterns
to connection handlers. In addition to the connection, handlers receive
parameters captured in the URL as keyword arguments.

Here's an example::


    from websockets.asyncio.router import route
    from werkzeug.routing import Map, Rule

    async def channel_handler(websocket, channel_id):
        ...

    url_map = Map([
        Rule("/channel/<uuid:channel_id>", endpoint=channel_handler),
        ...
    ])

    # set this future to exit the server
    stop = asyncio.get_running_loop().create_future()

    async with route(url_map, ...) as server:
        await stop


Refer to the documentation of :mod:`werkzeug.routing` for details.

If you define redirects with ``Rule(..., redirect_to=...)`` in the URL map,
when the server runs behind a reverse proxy that modifies the ``Host``
header or terminates TLS, you need additional configuration:

* Set ``server_name`` to the name of the server as seen by clients. When
  not provided, websockets uses the value of the ``Host`` header.

* Set ``ssl=True`` to generate ``wss://`` URIs without enabling TLS.
  Under the hood, this bind the URL map with a ``url_scheme`` of
  ``wss://`` instead of ``ws://``.

There is no need to specify ``websocket=True`` in each rule. It is added
automatically.

Args:
    url_map: Mapping of URL patterns to connection handlers.
    server_name: Name of the server as seen by clients. If :obj:`None`,
        websockets uses the value of the ``Host`` header.
    ssl: Configuration for enabling TLS on the connection. Set it to
        :obj:`True` if a reverse proxy terminates TLS connections.
    create_router: Factory for the :class:`Router` dispatching requests to
        handlers. Set it to a wrapper or a subclass to customize routing.

NÚwsÚwssTr   Úprocess_requestc              “  óŠ   >#   • T" X5      n[        U[        5      (       a
  UI S h  v•N nUb  U$ TR                  X5      $  N7f©N)Ú
isinstancer   Úroute_request)Ú
connectionÚrequestÚresponseÚ_process_requestÚrouters      €€ÚS/var/www/html/gaurav/venv/lib/python3.13/site-packages/websockets/asyncio/router.pyr   Úroute.<locals>.process_requestˆ   sG   øé € ñ ,¨JÓ@�Ü˜h¬	×2Ñ2Ø%-Ÿ~�HØÑ'Ø#�OØ×+Ñ+¨JÓ@Ð@ñ  .ùs   ƒ#A¦A§A©r    r   r!   r	   ÚreturnzResponse | None)r   Úpopr   r   Úhandler)
Úurl_mapr   r   r   ÚargsÚkwargsÚ
url_schemer   r#   r$   s
           @@r%   r   r   (   s¯   ù€ ðR !™[‘T¨eˆ
Ø�dŠ?˜s™Ø�5‰MàÑ Ü"ˆMá˜w°ZÓ@ˆð �J‰JÐ(¨$Ó/ð 	ð Ñ#ð ×$Ñ$ñ ðAØ,ðAØ7>ðAà ÷Að Aô �V—^‘^ÐV dÒV¸OÐVÈvÑVÐVó    c                ó    • [        U 4SUS.UD6$ )a2  
Create a WebSocket Unix server dispatching connections to different handlers.

:func:`unix_route` combines the behaviors of :func:`route` and
:func:`~websockets.asyncio.server.unix_serve`.

Args:
    url_map: Mapping of URL patterns to connection handlers.
    path: File system path to the Unix socket.

T)ÚunixÚpath)r   ©r+   r2   r-   s      r%   r   r   ”   s   € ô  �WÐ= 4¨dÑ=°fÑ=Ð=r/   c               ó   • [        S5      e)Nzroute() requires werkzeug©ÚImportError)r+   r   r   r   r,   r-   s         r%   r   r      s   € ô Ð5Ó6Ð6r/   c                ó   • [        S5      e)Nzunix_route() requires werkzeugr5   r3   s      r%   r   r      s   € ô
 Ð:Ó;Ð;r/   c                  óv   • \ rS rSrSr  S       SS jjrSS jrSS jrSS jr      SS jr	SS	 jr
S
rg)r   é§   z*WebSocket router supporting :func:`route`.Nc                óx   • Xl         X l        X0l        U R                   R                  5        H
  nSUl        M     g )NT)r+   r   r.   Ú
iter_rulesÚ	websocket)Úselfr+   r   r.   Úrules        r%   Ú__init__ÚRouter.__init__ª   s2   € ð ŒØ&ÔØ$ŒØ—L‘L×+Ñ+Ö-ˆDØ!ˆDŽNò .r/   c                óR   • U R                   c  UR                  S   $ U R                   $ )NÚHost)r   Úheaders)r=   r    r!   s      r%   Úget_server_nameÚRouter.get_server_name¶   s)   € Ø×ÑÑ#Ø—?‘? 6Ñ*Ð*à×#Ñ#Ð#r/   c                ó|   • UR                  [        R                  R                  SU 35      nX#R                  S'   U$ )Nz	Found at ÚLocation)ÚrespondÚhttpÚ
HTTPStatusÚFOUNDrC   )r=   r    Úurlr"   s       r%   ÚredirectÚRouter.redirect¼   s8   € Ø×%Ñ%¤d§o¡o×&;Ñ&;¸yÈÈÐ=NÓOˆØ'*×Ñ˜Ñ$Øˆr/   c                óV   • UR                  [        R                  R                  S5      $ )Nz	Not Found)rH   rI   rJ   Ú	NOT_FOUND©r=   r    s     r%   Ú	not_foundÚRouter.not_foundÁ   s   € Ø×!Ñ!¤$§/¡/×";Ñ";¸[ÓIÐIr/   c                óÂ  • U R                   R                  U R                  X5      U R                  S9n [        R
                  R                  UR                  5      nUR                  UR                  UR                  S9u  pVXVsUl        Ul        g! [         a%  nU R                  XR                  5      s SnA$ SnAf[         a    U R                  U5      s $ f = f)zRoute incoming request.)r   r.   )Ú	path_infoÚ
query_argsN)r+   ÚbindrD   r.   ÚurllibÚparseÚurlparser2   ÚmatchÚqueryr   rM   Únew_urlr   rR   r*   Úhandler_kwargs)r=   r    r!   Úurl_map_adapterÚparsedr*   r-   rM   s           r%   r   ÚRouter.route_requestÄ   sÈ   € ð Ÿ,™,×+Ñ+Ø×,Ñ,¨ZÓAØ—‘ð ,ð 
ˆð		.Ü—\‘\×*Ñ*¨7¯<©<Ó8ˆFØ-×3Ñ3Ø Ÿ+™+Ø!Ÿ<™<ð 4ð ‰OˆGð 9@Ð5ˆ
Ô˜JÔ5Øøô ó 	?Ø—=‘= ×-=Ñ-=Ó>Õ>ûÜó 	.Ø—>‘> *Ó-Ò-ð	.ús$   µAB Â
CÂB=Â7CÂ=CÃCc              ƒ  óX   #   • UR                   " U40 UR                  D6I Sh  v•N $  N7f)zHandle a connection.N)r*   r^   rQ   s     r%   r*   ÚRouter.handlerÙ   s'   é € à×'Ò'¨
ÑP°j×6OÑ6OÑP×PÐPÑPùs   ‚!*£(¤*)r   r+   r.   )Nr   )r+   r   r   ú
str | Noner.   Ústrr(   ÚNone)r    r   r!   r	   r(   re   )r    r   rL   re   r(   r
   )r    r   r(   r
   r'   )r    r   r(   rf   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r?   rD   rM   rR   r   r*   Ú__static_attributes__© r/   r%   r   r   §   sk   † Ù4ð
 #'Øð	
"àð
"ð  ð
"ð ð	
"ð
 
õ
"ô$ôô
JðØ*ðØ5<ðà	ô÷*Qr/   r   )r+   r   r,   r   r   rd   r   z,ssl_module.SSLContext | Literal[True] | Noner   ztype[Router] | Noner-   r   r(   úAwaitable[Server]r   )r+   r   r2   rd   r-   r   r(   rn   )Ú
__future__r   rI   r   Ú
ssl_moduleÚurllib.parserX   Útypingr   r   r   r   Úhttp11r	   r
   Úserverr   r   r   Ú__all__Úwerkzeug.exceptionsr   Úwerkzeug.routingr   r   r   r   r6   r   rm   r/   r%   Ú<module>rx      sb  ðÝ "ã Û Û ß 4Ó 4ç &ß 3Ñ 3ò ,€ðU>Ý,ß5ð4 #'Ø<@Ø-1ñjWØðjWàðjWð  ðjWð :ð	jWð
 +ðjWð ðjWð 
õjWð\  ð>Øð>àð>ð ð>ð 
õ	>÷&4Qò 4Qøði ó <ð
 #'Ø<@Ø-1ñ7Øð7àð7ð  ð7ð :ð	7ð
 +ð7ð ð7ð 
õ7ð  ð<Øð<àð<ð ð<ð 
÷	<ð<ús   ¶A6 Á6-B&Â%B&