Routes are wrapped function objects that are called upon a HTTP request.
Classes
Route (function, *, …) |
A route object is a wrapped function. |
kyoukai.route.
Route
(function, *, reverse_hooks: bool = False, should_invoke_hooks: bool = True, do_argument_checking: bool = True, endpoint: str = None)[source]¶Bases: object
A route object is a wrapped function. They invoke this function when invoked on routing and calling.
Parameters: |
|
---|
do_argument_checking
= None¶If this route should do argument checking.
routes
= None¶A list of tuples (url, methods) for this Route.
endpoint
= None¶The custom endpoint for this route. Could be None.
hooks
= None¶Our own specific hooks.
add_path
(url, methods=('GET', 'HEAD'))[source]¶Adds a path to the current set of paths for this route.
Parameters: |
---|
The URL and methods will be added as a pair.
get_submount
()[source]¶Return type: | Submount |
---|---|
Returns: | A submount that represents this route. |
New in version 2.2.0.
Changed in version 2.x.x: Changed from getting a list of rules to a single submount object.
get_endpoint_name
(bp=None)[source]¶Gets the endpoint name for this route.
Parameters: | bp – The Blueprint to use for name calculation. |
---|---|
Return type: | str |
Returns: | The endpoint that can be used. |
invoke_function
(self, ctx, pre_hooks, post_hooks, params)[source]¶Invokes the underlying callable. This is for use in chaining routes.
Parameters: |
|
---|---|
Returns: | The result of the invoked function. |
check_route_args
(params=None)[source]¶Checks the arguments for a route.
Parameters: | params (Optional [dict ]) – The parameters passed in, as a dict. |
---|---|
Raises: | TypeError – If the arguments passed in were not correct. |
add_hook
(type_, hook)[source]¶Adds a hook to the current Route.
Parameters: |
|
---|
get_hooks
(type_)[source]¶Gets the hooks for the current Route for the type.
Parameters: | type (str ) – The type to get. |
---|---|
Returns: | A list of callables. |
invoke
(self, ctx, args=(), params=None)[source]¶Invokes a route. This will run the underlying function.
Parameters: |
|
---|---|
Return type: | |
Returns: | The result of the route’s function. |