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 | |
handler_signature
property
¶
handler_signature
Returns the Signature of the handler function.
This property returns the Signature object representing the signature of the handler function. The Signature object provides information about the parameters, return type, and annotations of the handler function.
Returns: - Signature: The Signature object representing the signature of the handler function.
Example:
handler = Dispatcher() signature = handler.handler_signature print(signature)
Note:
- The Signature object is created using the from_callable method of the Signature class.
- The from_callable method takes a callable object (in this case, the handler function) as input and returns a Signature object.
- The Signature object can be used to inspect the parameters and return type of the handler function.
path_parameters
property
¶
path_parameters
Gets the path parameters in a set format.
This property returns a set of path parameters used in the URL pattern of the handler. Each path parameter represents a dynamic value that is extracted from the URL during routing.
Returns: - Set[str]: A set of path parameters.
Example:
handler = Dispatcher() parameters = handler.path_parameters print(parameters)
Note: - The path parameters are extracted from the URL pattern defined in the handler's route. - The path parameters are represented as strings. - If no path parameters are defined in the URL pattern, an empty set will be returned.
stringify_parameters
property
¶
stringify_parameters
Gets the param:type in string like list.
Used for the directive lilya show-urls.
parent_levels
property
¶
parent_levels
Returns the handler from the app down to the route handler.
This property returns a list of all the parent levels of the current handler. Each parent level represents a higher level in the routing hierarchy.
Example: Consider the following routing hierarchy: app = Ravyn(routes=[ Include(path='/api/v1', routes=[ Gateway(path='/home', handler=home) ]) ])
In this example, the parent of the Gateway handler is the Include handler. The parent of the Include handler is the Ravyn router. The parent of the Ravyn router is the Ravyn app itself.
The parent_levels property uses a while loop to traverse the parent hierarchy.
It starts with the current handler and iteratively adds each parent level to a list.
Finally, it reverses the list to maintain the correct order of parent levels.
Returns: - list[Any]: A list of parent levels, starting from the current handler and going up to the app level.
Note:
- The parent levels are determined based on the parent attribute of each handler.
- If there are no parent levels (i.e., the current handler is the top-level handler), an empty list will be returned.
dependency_names
property
¶
dependency_names
Returns a unique set of all dependency names provided in the handlers parent levels.
This property retrieves the dependencies from each parent level of the handler and collects all the dependency names in a set. It ensures that the set only contains unique dependency names.
Returns: - Set[str]: A set of unique dependency names.
Example:
handler = Dispatcher() dependency_names = handler.dependency_names print(dependency_names)
Note: - If no dependencies are defined in any of the parent levels, an empty set will be returned. - The dependencies are collected from all parent levels, ensuring that there are no duplicate dependency names in the final set.
exception_handlers
instance-attribute
¶
exception_handlers = (
{}
if exception_handlers is None
else dict(exception_handlers)
)
wrapped_permissions
instance-attribute
¶
wrapped_permissions = [
(wrap_permission(permission))
for permission in (permissions or [])
]
path
instance-attribute
¶
path = _resolve_path(
path,
getattr(handler, "path", "/"),
is_from_router=is_from_router,
)
is_class_based
staticmethod
¶
is_class_based(handler)
Checks if the handler object or class is a subclass or instance of BaseController.
Source code in ravyn/routing/gateways.py
31 32 33 34 35 36 37 38 | |
is_handler
staticmethod
¶
is_handler(handler)
Checks if the callable is a standalone function/method and NOT a BaseController instance/subclass.
Source code in ravyn/routing/gateways.py
40 41 42 43 44 45 46 | |
generate_operation_id
¶
generate_operation_id(name, handler)
Generates a unique, normalized operation ID suitable for OpenAPI specification.
The ID is constructed from the handler's base name/class name and the route path, often appended with the primary HTTP method.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The explicit name given to the route (if any).
TYPE:
|
handler
|
The handler object (HTTPHandler, WebSocketHandler, or BaseController instance).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A cleaned string suitable for use as an OpenAPI operationId. |
Source code in ravyn/routing/gateways.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
handle_middleware
staticmethod
¶
handle_middleware(handler, base_middleware)
Normalizes a list of middleware classes/instances into a list of DefineMiddleware instances.
Merges handler-defined middleware with Gateway-level middleware.
| PARAMETER | DESCRIPTION |
|---|---|
handler
|
The route handler object.
TYPE:
|
base_middleware
|
The list of middleware defined at the Gateway level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Middleware]
|
A list of |
Source code in ravyn/routing/gateways.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
parse_path
¶
parse_path(path)
Using the Lilya TRANSFORMERS and the application registered convertors, transforms the path into a PathParameterSchema used for the OpenAPI definition.
Source code in ravyn/routing/core/base.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
get_response_for_handler
¶
get_response_for_handler()
Checks and validates the type of return response and maps to the corresponding handler with the given parameters.
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Any], Awaitable[Response]]
|
Callable[[Any], Awaitable[LilyaResponse]]: The response handler function. |
Source code in ravyn/routing/core/base.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
get_response_for_request
async
¶
get_response_for_request(
scope, request, route, parameter_model
)
Get response for the given request using the specified route and parameter model.
| PARAMETER | DESCRIPTION |
|---|---|
scope
|
The scope of the request.
TYPE:
|
request
|
The incoming request.
TYPE:
|
route
|
The route handler for the request.
TYPE:
|
parameter_model
|
The parameter model for handling request parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LilyaResponse
|
The response generated for the request.
TYPE:
|
Source code in ravyn/routing/core/base.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
create_signature_model
¶
create_signature_model(is_websocket=False)
Creates a signature model for the given route.
Websockets do not support methods.
Source code in ravyn/routing/core/base.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
create_handler_transformer_model
¶
create_handler_transformer_model()
Method to create a TransformerModel for a given handler.
Source code in ravyn/routing/core/base.py
139 140 141 142 143 144 145 146 147 148 | |
get_lookup_path
¶
get_lookup_path(ignore_first=True)
Constructs and returns the lookup path for the current object by traversing its parent hierarchy.
The method collects the 'name' attribute of the current object and its ancestors, if they exist, and returns them as a list in reverse order (from the root ancestor to the current object).
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
list[str]: A list of names representing the lookup path from the root |
list[str]
|
ancestor to the current object. |
Source code in ravyn/routing/core/base.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | |
get_dependencies
¶
get_dependencies()
Returns all dependencies of the handler function's starting from the parent levels.
This method retrieves all the dependencies of the handler function by iterating over each parent level. It collects the dependencies defined in each level and stores them in a dictionary.
Returns: - Dependencies: A dictionary containing all the dependencies of the handler function.
Raises:
- RuntimeError: If get_dependencies is called before a signature model has been generated.
Example:
handler = Dispatcher() dependencies = handler.get_dependencies() print(dependencies)
Note: - If no dependencies are defined in any of the parent levels, an empty dictionary will be returned. - Each dependency is represented by a key-value pair in the dictionary, where the key is the dependency name and the value is the dependency object. - The dependencies are collected from all parent levels, ensuring that there are no duplicate dependencies in the final dictionary.
Source code in ravyn/routing/core/base.py
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 | |
is_unique_dependency
staticmethod
¶
is_unique_dependency(dependencies, key, injector)
Validates that a given inject has not been already defined under a different key in any of the levels.
This method takes in a dictionary of dependencies, a key, and an injector. It checks if the injector is already defined in the dependencies dictionary under a different key.
Parameters: - dependencies (Dependencies): A dictionary of dependencies. - key (str): The key to check for uniqueness. - injector (Inject): The injector to check.
Raises: - ImproperlyConfigured: If the injector is already defined under a different key in the dependencies dictionary.
Example:
dependencies = {"db": injector1, "logger": injector2} key = "db" injector = injector3 is_unique_dependency(dependencies, key, injector)
This method iterates over each key-value pair in the dependencies dictionary. If the value matches the given injector, it raises an ImproperlyConfigured exception with a detailed error message.
Note: - The dependencies dictionary is expected to have string keys and values of type Inject. - The key parameter should be a string representing the key to check for uniqueness. - The injector parameter should be an instance of the Inject class.
Source code in ravyn/routing/core/base.py
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 | |
get_cookies
¶
get_cookies(local_cookies, other_cookies=None)
Returns a unique list of cookies.
This method takes two sets of cookies, local_cookies and other_cookies,
and returns a list of dictionaries representing the normalized cookies.
Parameters: - local_cookies (ResponseCookies): The set of local cookies. - other_cookies (ResponseCookies): The set of other cookies.
Returns: - list[dict[str, Any]]: A list of dictionaries representing the normalized cookies.
The method first creates a filtered list of cookies by combining the local_cookies
and other_cookies sets. It ensures that only unique cookies are included in the list.
Then, it normalizes each cookie by converting it into a dictionary representation, excluding the 'description' attribute. The normalized cookies are stored in a list.
Finally, the method returns the list of normalized cookies.
Note: - The 'description' attribute is excluded from the normalized cookies.
Example usage:
local_cookies = [...]
other_cookies = [...]
normalized_cookies = get_cookies(local_cookies, other_cookies)
print(normalized_cookies)
This will output the list of normalized cookies.
Source code in ravyn/routing/core/base.py
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 | |
get_headers
¶
get_headers(headers)
Returns a dictionary of response headers.
Parameters: - headers (ResponseHeaders): The response headers object.
Returns: - dict[str, Any]: A dictionary containing the response headers.
Example:
headers = {"Content-Type": "application/json", "Cache-Control": "no-cache"} response_headers = get_headers(headers) print(response_headers)
This method takes a ResponseHeaders object and converts it into a dictionary
of response headers. Each key-value pair in the ResponseHeaders object is
added to the dictionary.
Note:
- The ResponseHeaders object is expected to have string keys and values.
- If the ResponseHeaders object is empty, an empty dictionary will be returned.
Source code in ravyn/routing/core/base.py
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 | |
get_response_data
async
¶
get_response_data(data)
Retrieves the response data for synchronous and asynchronous operations.
This method takes in a data parameter, which can be either a regular value or an awaitable object.
If data is an awaitable object, it will be awaited to retrieve the actual response data.
If data is a regular value, it will be returned as is.
Parameters: - data (Any): The response data, which can be either a regular value or an awaitable object.
Returns: - Any: The actual response data.
Example usage:
response_data = await get_response_data(some_data)
Source code in ravyn/routing/core/base.py
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 | |
allow_connection
async
¶
allow_connection(connection, permission)
Asynchronously allows a connection based on the provided permission.
| PARAMETER | DESCRIPTION |
|---|---|
permission
|
The permission object to check.
TYPE:
|
connection
|
The connection object representing the request.
TYPE:
|
Returns: None Raises: PermissionException: If the permission check fails.
Source code in ravyn/routing/core/base.py
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | |
dispatch_allow_connection
async
¶
dispatch_allow_connection(
permissions,
connection,
scope,
receive,
send,
dispatch_call,
)
Dispatches a connection based on the provided permissions.
| PARAMETER | DESCRIPTION |
|---|---|
permissions
|
A dictionary mapping permission levels to either an asynchronous callable or a DefinePermission instance.
TYPE:
|
connection
|
The connection object to be dispatched.
TYPE:
|
scope
|
The scope of the connection.
TYPE:
|
receive
|
The receive channel for the connection.
TYPE:
|
send
|
The send channel for the connection.
TYPE:
|
Returns: None
Source code in ravyn/routing/core/base.py
918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 | |
get_security_schemes
¶
get_security_schemes()
Returns a list of all security schemes associated with the handler.
This method iterates over each parent level of the handler and collects the security schemes defined in each level. The collected security schemes are stored in a list and returned.
Returns: - list[SecurityScheme]: A list of security schemes associated with the handler.
Example:
handler = Dispatcher() security_schemes = handler.get_security_schemes() print(security_schemes) [SecurityScheme(name='BearerAuth', type='http', scheme='bearer', bearer_format='JWT'), SecurityScheme(name='ApiKeyAuth', type='apiKey', in_='header', name='X-API-Key')]
Note: - If no security schemes are defined in any of the parent levels, an empty list will be returned. - Each security scheme is represented by an instance of the SecurityScheme class. - The SecurityScheme class has attributes such as name, type, scheme, bearer_format, in_, and name, which provide information about the security scheme.
Source code in ravyn/routing/core/base.py
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
get_handler_tags
¶
get_handler_tags()
Returns all the tags associated with the handler by checking the parents as well.
This method retrieves all the tags associated with the handler by iterating over each parent level. It collects the tags defined in each level and stores them in a list.
Returns: - list[str]: A list of tags associated with the handler.
Example:
handler = Dispatcher() tags = handler.get_handler_tags() print(tags) ['api', 'user']
Note: - If no tags are defined in any of the parent levels, an empty list will be returned. - Each tag is represented as a string. - The tags are collected from all parent levels, ensuring that there are no duplicate tags in the final list.
Source code in ravyn/routing/core/base.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | |
handle_signature
¶
handle_signature()
Validates the return annotation of a handler
if enforce_return_annotation is set to True.
Source code in lilya/routing.py
718 719 720 721 722 723 724 725 726 727 728 729 730 | |
search
¶
search(scope)
Searches within the route patterns and matches against the regex.
If found, then dispatches the request to the handler of the object.
| PARAMETER | DESCRIPTION |
|---|---|
scope
|
The request scope.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Match, Scope]
|
Tuple[Match, Scope]: The match result and child scope. |
Source code in lilya/routing.py
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 | |
path_for
¶
path_for(name, **path_params)
Generates a URL path for the specified route name and parameters.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the route.
TYPE:
|
path_params
|
The path parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
URLPath
|
The generated URL path.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
NoMatchFound
|
If there is no match for the given name and parameters. |
Source code in lilya/routing.py
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 | |
url_path_for
¶
url_path_for(name, /, **path_params)
Generates a URL path for the specified route name and parameters.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the route.
TYPE:
|
path_params
|
The path parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
URLPath
|
The generated URL path.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
NoMatchFound
|
If there is no match for the given name and parameters. |
Source code in lilya/routing.py
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 | |
dispatch
async
¶
dispatch(scope, receive, send)
Dispatches the request to the appropriate handler.
| PARAMETER | DESCRIPTION |
|---|---|
scope
|
The request scope.
TYPE:
|
receive
|
The receive channel.
TYPE:
|
send
|
The send channel.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
Source code in lilya/routing.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
handle_not_found
async
¶
handle_not_found(scope, receive, send)
Handles the case when no match is found.
| PARAMETER | DESCRIPTION |
|---|---|
scope
|
The request scope.
TYPE:
|
receive
|
The receive channel.
TYPE:
|
send
|
The send channel.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
Source code in lilya/routing.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
handle_not_found_fallthrough
async
staticmethod
¶
handle_not_found_fallthrough(scope, receive, send)
Source code in lilya/routing.py
182 183 184 | |
handle_exception_handlers
async
¶
handle_exception_handlers(scope, receive, send, exc)
Manages exception handlers for HTTP and WebSocket scopes.
| PARAMETER | DESCRIPTION |
|---|---|
scope
|
The ASGI scope.
TYPE:
|
receive
|
The receive function.
TYPE:
|
send
|
The send function.
TYPE:
|
exc
|
The exception to handle.
TYPE:
|
Source code in lilya/routing.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
extract_request_information
¶
extract_request_information(request, signature)
Extracts the information and flattens the request dictionaries in the handler.
Source code in lilya/_internal/_responses.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
handle_response
¶
handle_response(func, other_signature=None)
Decorator for creating a request-response ASGI application.
| PARAMETER | DESCRIPTION |
|---|---|
func
|
The function to be wrapped.
TYPE:
|
other_signature
|
Another passed signature
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ASGIApp
|
The ASGI application.
TYPE:
|
Source code in lilya/_internal/_responses.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
extract_request_params_information
¶
extract_request_params_information(request, signature)
Extracts the request information from the request and populates the request information.
Source code in lilya/_internal/_responses.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
is_explicitly_bound
¶
is_explicitly_bound(param)
Checks for explicitly bound parameter from the default.
Source code in lilya/_internal/_responses.py
361 362 363 364 365 366 367 368 369 370 | |
handle_websocket_session
¶
handle_websocket_session(func)
Decorator for creating a WebSocket session ASGI application.
| PARAMETER | DESCRIPTION |
|---|---|
func
|
The function to be wrapped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ASGIApp
|
The ASGI application.
TYPE:
|
Source code in lilya/_internal/_responses.py
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 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 | |
handle_match
¶
handle_match(scope, match)
Handles the case when a match is found in the route patterns.
| PARAMETER | DESCRIPTION |
|---|---|
scope
|
The request scope.
TYPE:
|
match
|
The match object from the regex.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Match, Scope]
|
Tuple[Match, Scope]: The match result and child scope. |
Source code in lilya/routing.py
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |
validate_params
¶
validate_params(name, path_params)
Validates the route name and path parameters.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the route.
TYPE:
|
path_params
|
The path parameters.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
NoMatchFound
|
If there is a mismatch in route name or parameters. |
Source code in lilya/routing.py
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | |
handle_dispatch
async
¶
handle_dispatch(scope, receive, send)
Handles the interception of messages and calls from the API.
Source code in ravyn/routing/gateways.py
860 861 862 863 864 | |
- path
- handler
- parent
- dependencies
- middleware
- interceptors
- permissions
- exception_handlers
- deprecated
- is_from_router
- security
- tags