Called before the request is dispatched. Calls :attr:`url_value_preprocessors` registered with the app and the current blueprint (if any). Then calls :attr:`before_request_funcs` registered with the app and the blueprint. If any :meth:`before_request` handler returns
(self)
| 1269 | return rv |
| 1270 | |
| 1271 | def preprocess_request(self) -> ft.ResponseReturnValue | None: |
| 1272 | """Called before the request is dispatched. Calls |
| 1273 | :attr:`url_value_preprocessors` registered with the app and the |
| 1274 | current blueprint (if any). Then calls :attr:`before_request_funcs` |
| 1275 | registered with the app and the blueprint. |
| 1276 | |
| 1277 | If any :meth:`before_request` handler returns a non-None value, the |
| 1278 | value is handled as if it was the return value from the view, and |
| 1279 | further request handling is stopped. |
| 1280 | """ |
| 1281 | names = (None, *reversed(request.blueprints)) |
| 1282 | |
| 1283 | for name in names: |
| 1284 | if name in self.url_value_preprocessors: |
| 1285 | for url_func in self.url_value_preprocessors[name]: |
| 1286 | url_func(request.endpoint, request.view_args) |
| 1287 | |
| 1288 | for name in names: |
| 1289 | if name in self.before_request_funcs: |
| 1290 | for before_func in self.before_request_funcs[name]: |
| 1291 | rv = self.ensure_sync(before_func)() |
| 1292 | |
| 1293 | if rv is not None: |
| 1294 | return rv # type: ignore[no-any-return] |
| 1295 | |
| 1296 | return None |
| 1297 | |
| 1298 | def process_response(self, response: Response) -> Response: |
| 1299 | """Can be overridden in order to modify the response object |
no test coverage detected