Gateway class¶
This is the reference for the Gateway that contains all the parameters,
attributes and functions.
How to import¶
from ravyn import Gateway
ravyn.Gateway
¶
Gateway(
path=None,
*,
handler,
name=None,
include_in_schema=True,
parent=None,
dependencies=None,
middleware=None,
interceptors=None,
permissions=None,
exception_handlers=None,
before_request=None,
after_request=None,
deprecated=None,
is_from_router=False,
security=None,
tags=None,
operation_id=None,
)
Bases: Path, Dispatcher, _GatewayCommon
Gateway object class used by Ravyn routes.
The Gateway act as a brigde between the router handlers and the main Ravyn routing system.
Read more about Gateway and how to use it.
Example
from ravyn import Ravyn. get
@get()
async def home() -> str:
return "Hello, World!"
Gateway(path="/home", 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:
|
include_in_schema
|
Boolean flag indicating if it should be added to the OpenAPI docs.
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. Example
TYPE:
|
after_request
|
A Read more about the events. Example
TYPE:
|
deprecated
|
Boolean flag for indicating the deprecation of the Gateway and to display it in the OpenAPI documentation..
TYPE:
|
is_from_router
|
Used by the
TYPE:
|
security
|
Used by OpenAPI definition, the security must be compliant with the norms. Ravyn offers some out of the box solutions where this is implemented. The Ravyn security is available to automatically used. The security can be applied also on a level basis. For custom security objects, you must subclass
TYPE:
|
tags
|
A list of strings tags to be applied to the path operation. It will be added to the generated OpenAPI documentation. Note almost everything in Ravyn can be done in levels, which means these tags on a Ravyn instance, means it will be added to every route even if those routes also contain tags.
TYPE:
|
operation_id
|
Unique operation id that allows distinguishing the same handler in different Gateways. Used for OpenAPI purposes.
TYPE:
|
Source code in ravyn/routing/gateways.py
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 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 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 | |