WebSocketGateway class¶
This is the reference for the WebSocketGateway that contains all the parameters,
attributes and functions.
How to import¶
from ravyn import WebSocketGateway
ravyn.WebSocketGateway
¶
WebSocketGateway(
path=None,
*,
handler,
name=None,
parent=None,
dependencies=None,
middleware=None,
interceptors=None,
permissions=None,
exception_handlers=None,
before_request=None,
after_request=None,
is_from_router=False,
)
Bases: WebSocketPath, Dispatcher, _GatewayCommon
WebSocketGateway object class used by Ravyn routes.
The WebSocketGateway act as a brigde between the router handlers and the main Ravyn routing system.
Read more about WebSocketGateway and how to use it.
Example
from ravyn import Ravyn. websocket
@websocket()
async def world_socket(socket: Websocket) -> None:
await socket.accept()
msg = await socket.receive_json()
assert msg
assert socket
await socket.close()
WebSocketGateway(path="/ws", handler=home)
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Relative path of the Example Example with parameters
TYPE:
|
handler
|
An instance of handler.
TYPE:
|
name
|
The name for the Gateway. The name can be reversed by
TYPE:
|
parent
|
Who owns the Gateway. If not specified, the application automatically it assign it. This is directly related with the application levels.
TYPE:
|
dependencies
|
A dictionary of string and Inject instances enable application level dependency injection.
TYPE:
|
middleware
|
A list of middleware to run for every request. The middlewares of a Gateway will be checked from top-down or Lilya Middleware as they are both converted internally. Read more about Python Protocols.
TYPE:
|
interceptors
|
A list of interceptors to serve the application incoming requests (HTTP and Websockets).
TYPE:
|
permissions
|
A list of permissions to serve the application incoming requests (HTTP and Websockets).
TYPE:
|
exception_handlers
|
A dictionary of exception types (or custom exceptions) and the handler functions on an application top level. Exception handler callables should be of the form of
TYPE:
|
before_request
|
A Read more about the events.
TYPE:
|
after_request
|
A Read more about the events.
TYPE:
|
is_from_router
|
Used by the
TYPE:
|
Source code in ravyn/routing/gateways.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 | |