|
10 | 10 | from enum import Enum |
11 | 11 | from functools import partial |
12 | 12 | from http import HTTPStatus |
13 | | -from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union |
| 13 | +from typing import Any, Callable, Dict, List, Match, Optional, Pattern, Set, Tuple, Type, Union |
14 | 14 |
|
15 | 15 | from aws_lambda_powertools.event_handler import content_types |
16 | 16 | from aws_lambda_powertools.event_handler.exceptions import NotFoundError, ServiceError |
@@ -167,7 +167,7 @@ class Route: |
167 | 167 | """Internally used Route Configuration""" |
168 | 168 |
|
169 | 169 | def __init__( |
170 | | - self, method: str, rule: Any, func: Callable, cors: bool, compress: bool, cache_control: Optional[str] |
| 170 | + self, method: str, rule: Pattern, func: Callable, cors: bool, compress: bool, cache_control: Optional[str] |
171 | 171 | ): |
172 | 172 | self.method = method.upper() |
173 | 173 | self.rule = rule |
@@ -446,10 +446,6 @@ def __init__( |
446 | 446 | # Allow for a custom serializer or a concise json serialization |
447 | 447 | self._serializer = serializer or partial(json.dumps, separators=(",", ":"), cls=Encoder) |
448 | 448 |
|
449 | | - if self._debug: |
450 | | - # Always does a pretty print when in debug mode |
451 | | - self._serializer = partial(json.dumps, indent=4, cls=Encoder) |
452 | | - |
453 | 449 | def route( |
454 | 450 | self, |
455 | 451 | rule: str, |
@@ -496,7 +492,7 @@ def resolve(self, event, context) -> Dict[str, Any]: |
496 | 492 | Returns the dict response |
497 | 493 | """ |
498 | 494 | if self._debug: |
499 | | - print(self._json_dump(event)) |
| 495 | + print(self._json_dump(event), end="") |
500 | 496 | BaseRouter.current_event = self._to_proxy_event(event) |
501 | 497 | BaseRouter.lambda_context = context |
502 | 498 | return self._resolve().build(self.current_event, self._cors) |
@@ -555,7 +551,7 @@ def _resolve(self) -> ResponseBuilder: |
555 | 551 | for route in self._routes: |
556 | 552 | if method != route.method: |
557 | 553 | continue |
558 | | - match_results: Optional[re.Match] = route.rule.match(path) |
| 554 | + match_results: Optional[Match] = route.rule.match(path) |
559 | 555 | if match_results: |
560 | 556 | logger.debug("Found a registered route. Calling function") |
561 | 557 | return self._call_route(route, match_results.groupdict()) # pass fn args |
|
0 commit comments