diff --git a/pyproject.toml b/pyproject.toml index e604b62..862e970 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "uhttp" -version = "1.3.5" +version = "1.3.6" description = "Stupid web development" authors = ["gus <0x67757300@gmail.com>"] license = "MIT" diff --git a/uhttp.py b/uhttp.py index 51849d2..45c3701 100644 --- a/uhttp.py +++ b/uhttp.py @@ -234,9 +234,14 @@ def index(request): ``` """ def decorator(func): - self._routes.setdefault(path, {}).update({ - method: func for method in methods - }) + for route in self._routes: + if re.fullmatch(route, path): + self._routes[route].update({ + method: func for method in methods + }) + break + else: + self._routes[path] = {method: func for method in methods} return func return decorator @@ -494,7 +499,7 @@ def __init__( self.description = HTTPStatus(status).phrase except ValueError: self.description = '' - super().__init__(self.description) + super().__init__(f'{self.status} {self.description}') self.headers = MultiDict(headers) """The response headers. @@ -516,9 +521,6 @@ def __init__( if not self.body and status in range(400, 600): self.body = str(self).encode() - def __repr__(self): - return f'{self.status} {self.description}' - @classmethod def from_any(cls, any): """Returns a Response from a sensible input.