Create a PageData object from the given router_data. Args: router_data: the router_data dict. Returns: A PageData object initialized with the provided router_data.
(cls, router_data: dict)
| 351 | |
| 352 | @classmethod |
| 353 | def from_router_data(cls, router_data: dict) -> "PageData": |
| 354 | """Create a PageData object from the given router_data. |
| 355 | |
| 356 | Args: |
| 357 | router_data: the router_data dict. |
| 358 | |
| 359 | Returns: |
| 360 | A PageData object initialized with the provided router_data. |
| 361 | """ |
| 362 | host = router_data.get(constants.RouteVar.HEADERS, {}).get("origin", "") |
| 363 | path = router_data.get(constants.RouteVar.PATH, "") |
| 364 | # raw_path is the browser-visible URL path, so it includes the configured |
| 365 | # frontend_path prefix. path remains the matched route pattern, which is |
| 366 | # defined without the prefix. |
| 367 | raw_path = get_config().prepend_frontend_path( |
| 368 | router_data.get(constants.RouteVar.ORIGIN, "") |
| 369 | ) |
| 370 | return cls( |
| 371 | host=host, |
| 372 | path=path, |
| 373 | raw_path=raw_path, |
| 374 | full_path=f"{host}{path}", |
| 375 | full_raw_path=f"{host}{raw_path}", |
| 376 | params=router_data.get(constants.RouteVar.QUERY, {}), |
| 377 | ) |
| 378 | |
| 379 | |
| 380 | @serializer(to=dict) |