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
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
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
509 510 511 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 542 543 544 | |
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
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | |
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
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 | |
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
138 139 140 141 142 143 144 145 146 147 | |
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
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 | |
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
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 | |
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
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 | |
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
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 881 882 | |
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
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | |
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
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 | |
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
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 | |
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
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
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
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 | |
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
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | |
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
777 778 779 780 781 782 783 784 785 786 787 788 789 | |
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
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 | |
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
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 | |
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
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 | |
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 | |
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
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 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 511 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 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
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
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | |
is_explicitly_bound
¶
is_explicitly_bound(param)
Checks for explicitly bound parameter from the default.
Source code in lilya/_internal/_responses.py
664 665 666 667 668 669 670 671 672 673 | |
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
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | |
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
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | |
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
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | |
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