router
Route dictionary.
Attributes
mlogger = get_logger(__name__)
module-attribute
ROUTE_VAR_SEP = ':'
module-attribute
Route = namedtuple('Route', ['pattern', 'method'])
module-attribute
RouteParam = namedtuple('RouteParam', ['key', 'value'])
module-attribute
Functions
route_match(route, path, method)
Test if route pattern matches given request path.
Source code in pyrevitlib/pyrevit/routes/server/router.py
extract_route_params(route_pattern, request_path)
Extracts route params from request path based on pattern.
Examples:
[Source code in pyrevitlib/pyrevit/routes/server/router.py
reset_routes()
get_routes(api_name)
Get all registered routes for given API name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_name |
str
|
unique name of the api |
required |
Returns:
Type | Description |
---|---|
dict[str, Caller[]]
|
registered routes |
Source code in pyrevitlib/pyrevit/routes/server/router.py
get_route_handler(api_name, path, method)
Return registered handler for given API, path, and method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_name |
str
|
unique name of the api |
required |
path |
str
|
request path |
required |
method |
str
|
method name |
required |
Returns:
Name | Type | Description |
---|---|---|
api_route |
Route
|
API route |
route_handler |
Caller
|
registered route handler function |
Source code in pyrevitlib/pyrevit/routes/server/router.py
add_route(api_name, pattern, method, handler_func)
Add new route for given API name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_name |
str
|
unique name of the api |
required |
pattern |
str
|
route pattern |
required |
method |
str
|
method name |
required |
handler_func |
function
|
route handler function |
required |
Source code in pyrevitlib/pyrevit/routes/server/router.py
remove_route(api_name, pattern, method)
Remove prevriously defined route for given API name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_name |
str
|
unique name of the api |
required |
pattern |
str
|
route pattern |
required |
method |
str
|
method name |
required |