🐛 add flag for fixing routes not prefixed with a slash
This commit is contained in:
parent
223c7f3cc6
commit
cf1a248538
1 changed files with 3 additions and 1 deletions
|
@ -40,6 +40,7 @@ class RoutesMixin:
|
|||
_error_routes: dict
|
||||
error_routes: dict[int, Callable]
|
||||
append_slash: bool
|
||||
fix_route_starting_slash: bool
|
||||
|
||||
def route(self, path, allowed_methods=None, name=None) -> Callable:
|
||||
"""
|
||||
|
@ -134,7 +135,8 @@ class RoutesMixin:
|
|||
or allowed_methods
|
||||
or DEFAULT_ALLOWED_METHODS
|
||||
)
|
||||
|
||||
if not path.startswith("/") and self.fix_route_starting_slash:
|
||||
path = "/" + path
|
||||
reverse_path = re.sub(r"<(.*?):(.*?)>", r"{\2}", path) if "<" in path else path
|
||||
|
||||
def get_packet(func):
|
||||
|
|
Loading…
Add table
Reference in a new issue