| @@ 70-86 (lines=17) @@ | ||
| 67 | ||
| 68 | return _decorator |
|
| 69 | ||
| 70 | def magic_route(self, rule, **options): |
|
| 71 | """Equivalent to the flask @route decorator |
|
| 72 | The injection container will try and bind all arguments |
|
| 73 | """ |
|
| 74 | ||
| 75 | def _decorator(f): |
|
| 76 | endpoint = options.pop("endpoint", None) |
|
| 77 | if f not in self._injection_map: |
|
| 78 | self._injection_map[f] = self._container.magic_partial( |
|
| 79 | f, shared=self._request_singletons |
|
| 80 | ) |
|
| 81 | self.flask_app.add_url_rule( |
|
| 82 | rule, endpoint, self._injection_map[f], **options |
|
| 83 | ) |
|
| 84 | return f |
|
| 85 | ||
| 86 | return _decorator |
|
| 87 | ||
| @@ 59-75 (lines=17) @@ | ||
| 56 | ||
| 57 | return _decorator |
|
| 58 | ||
| 59 | def magic_route(self, rule, **options): |
|
| 60 | """Equivalent to the flask @route decorator |
|
| 61 | The injection container will try and bind all arguments |
|
| 62 | """ |
|
| 63 | ||
| 64 | def _decorator(f): |
|
| 65 | endpoint = options.pop("endpoint", f.__name__) |
|
| 66 | if f not in self._injection_map: |
|
| 67 | self._injection_map[f] = self._container.magic_partial( |
|
| 68 | f, shared=self._request_singletons |
|
| 69 | ) |
|
| 70 | self.blueprint.add_url_rule( |
|
| 71 | rule, endpoint, self._injection_map[f], **options |
|
| 72 | ) |
|
| 73 | return f |
|
| 74 | ||
| 75 | return _decorator |
|
| 76 | ||