Skip to content

Commit

Permalink
fix: set correct path_template value for trie node
Browse files Browse the repository at this point in the history
  • Loading branch information
svlyubovsk committed Oct 21, 2024
1 parent 5255ec3 commit c59d48e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion litestar/_asgi/routing_trie/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def add_route_to_trie(
next_node_key = component

if next_node_key not in current_node.children:
current_node.children[next_node_key] = create_node(path_template=route.path_format)
current_node.children[next_node_key] = create_node()

current_node.child_keys = set(current_node.children.keys())
current_node = current_node.children[next_node_key]
Expand Down Expand Up @@ -140,6 +140,7 @@ def configure_node(
"""
from litestar.routes import HTTPRoute, WebSocketRoute

node.path_template = route.path_format
if not node.path_parameters:
node.path_parameters = {}

Expand Down
6 changes: 3 additions & 3 deletions litestar/_asgi/routing_trie/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class RouteTrieNode:
"children",
"is_asgi",
"is_mount",
"is_static",
"is_path_param_node",
"is_path_type",
"is_static",
"path_parameters",
"path_template",
)
Expand Down Expand Up @@ -68,7 +68,7 @@ class RouteTrieNode:
"""The path template string used to lower prometheus cardinality when group_path enabled"""


def create_node(path_template: str = "") -> RouteTrieNode:
def create_node() -> RouteTrieNode:
"""Create a RouteMapNode instance.
Returns:
Expand All @@ -85,5 +85,5 @@ def create_node(path_template: str = "") -> RouteTrieNode:
is_static=False,
is_path_type=False,
path_parameters={},
path_template=path_template,
path_template="",
)

0 comments on commit c59d48e

Please sign in to comment.