Skip to content

Commit

Permalink
join matching route patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
0x67757300 committed Jan 5, 2024
1 parent 4fe686a commit 8405579
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "uhttp"
version = "1.3.5"
version = "1.3.6"
description = "Stupid web development"
authors = ["gus <[email protected]>"]
license = "MIT"
Expand Down
16 changes: 9 additions & 7 deletions uhttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 8405579

Please sign in to comment.