Skip to content

WebhookGateway class

This is the reference for the WebhookGateway that contains all the parameters, attributes and functions.

How to import

from ravyn import WebhookGateway

ravyn.WebhookGateway

WebhookGateway(
    *,
    handler,
    name=None,
    include_in_schema=True,
    parent=None,
    deprecated=None,
    security=None,
    before_request=None,
    after_request=None,
    tags=None,
)

Bases: Path, Dispatcher, _GatewayCommon

WebhookGateway object class used by Ravyn routes.

The WebhookGateway act as a brigde between the webhook handlers and the main Ravyn routing system.

Read more about WebhookGateway and how to use it.

Note

This is used for OpenAPI documentation purposes only.

PARAMETER DESCRIPTION
handler

An instance of handler.

TYPE: Union[WebhookHandler, BaseController, Type[BaseController], Type[WebhookHandler]]

name

The name for the WebhookGateway.

TYPE: Optional[str] DEFAULT: None

include_in_schema

Boolean flag indicating if it should be added to the OpenAPI docs.

TYPE: bool DEFAULT: True

parent

Who owns the Gateway. If not specified, the application automatically it assign it.

This is directly related with the application levels.

TYPE: Optional[ParentType] DEFAULT: None

deprecated

Boolean flag for indicating the deprecation of the Gateway and to display it in the OpenAPI documentation..

TYPE: Optional[bool] DEFAULT: None

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 ravyn.openapi.security.base.HTTPBase object.

TYPE: Optional[Sequence[SecurityScheme]] DEFAULT: None

before_request

A list of events that are trigger after the application processes the request.

Read more about the events.

TYPE: Union[Sequence[Callable[[], Any]], None] DEFAULT: None

after_request

A list of events that are trigger after the application processes the request.

Read more about the events.

TYPE: Union[Sequence[Callable[[], Any]], None] DEFAULT: None

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: Optional[Sequence[str]] DEFAULT: None

Source code in ravyn/routing/gateways.py
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 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
 947
 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
 973
 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
1005
1006
1007
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
def __init__(
    self,
    *,
    handler: Annotated[
        Union["WebhookHandler", BaseController, Type[BaseController], Type["WebhookHandler"]],
        Doc(
            """
            An instance of [handler](https://ravyn.dev/routing/webhooks/#handlers).
            """
        ),
    ],
    name: Annotated[
        Optional[str],
        Doc(
            """
            The name for the WebhookGateway.
            """
        ),
    ] = None,
    include_in_schema: Annotated[
        bool,
        Doc(
            """
            Boolean flag indicating if it should be added to the OpenAPI docs.
            """
        ),
    ] = True,
    parent: Annotated[
        Optional["ParentType"],
        Doc(
            """
            Who owns the Gateway. If not specified, the application automatically it assign it.

            This is directly related with the [application levels](https://ravyn.dev/application/levels/).
            """
        ),
    ] = None,
    deprecated: Annotated[
        Optional[bool],
        Doc(
            """
            Boolean flag for indicating the deprecation of the Gateway and to display it
            in the OpenAPI documentation..
            """
        ),
    ] = None,
    security: Annotated[
        Optional[Sequence["SecurityScheme"]],
        Doc(
            """
            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](https://ravyn.dev/openapi/) is available to automatically used.

            The security can be applied also on a [level basis](https://ravyn.dev/application/levels/).

            For custom security objects, you **must** subclass
            `ravyn.openapi.security.base.HTTPBase` object.
            """
        ),
    ] = None,
    before_request: Annotated[
        Union[Sequence[Callable[[], Any]], None],
        Doc(
            """
            A `list` of events that are trigger after the application
            processes the request.

            Read more about the [events](https://lilya.dev/lifespan/).
            """
        ),
    ] = None,
    after_request: Annotated[
        Union[Sequence[Callable[[], Any]], None],
        Doc(
            """
            A `list` of events that are trigger after the application
            processes the request.

            Read more about the [events](https://lilya.dev/lifespan/).
            """
        ),
    ] = None,
    tags: Annotated[
        Optional[Sequence[str]],
        Doc(
            """
            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](https://ravyn.dev/application/levels/), which means
            these tags on a Ravyn instance, means it will be added to every route even
            if those routes also contain tags.
            """
        ),
    ] = None,
) -> None:
    raw_handler = handler
    handler = self._instantiate_if_controller(raw_handler, self)  # type: ignore

    self.path = getattr(handler, "path", "/")
    self.methods = getattr(handler, "http_methods", None)
    resolved_name = self._resolve_name(name, handler)

    self.handler = cast("Callable", handler)
    self.include_in_schema = include_in_schema
    self.name = resolved_name
    self.dependencies = {}
    self.interceptors = []  # type: ignore
    self.permissions = []
    self.middleware = []
    self.exception_handlers = {}
    self.response_class = None
    self.response_cookies = None
    self.response_headers = None
    self.deprecated = deprecated
    self.parent = parent
    self.security = security
    self.before_request = before_request
    self.after_request = after_request
    self.tags = list(tags or [])

    self._compile(handler, self.path)

    if self.is_handler(self.handler):
        self.handler.name = self.name
        if not getattr(handler, "operation_id", None):
            handler.operation_id = self.generate_operation_id(self.name, self.handler)  # type: ignore

handler instance-attribute

handler = cast('Callable', handler)

name instance-attribute

name = resolved_name

include_in_schema instance-attribute

include_in_schema = include_in_schema

parent instance-attribute

parent = parent

deprecated instance-attribute

deprecated = deprecated

security instance-attribute

security = security

tags instance-attribute

tags = list(tags or [])