2024-07-02 21:59:30 +02:00
|
|
|
use crate::{ssr::Js, Payload};
|
|
|
|
|
use axum::extract::{Path, Request};
|
|
|
|
|
use axum::response::Html;
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
pub async fn catch_all(
|
|
|
|
|
Path(params): Path<HashMap<String, String>>,
|
|
|
|
|
request: Request,
|
|
|
|
|
) -> Html<String> {
|
|
|
|
|
let pathname = &request.uri();
|
|
|
|
|
let headers = &request.headers();
|
|
|
|
|
|
|
|
|
|
let req = crate::Request::new(pathname, headers, params);
|
|
|
|
|
|
|
|
|
|
// TODO: remove unwrap
|
|
|
|
|
let payload = Payload::new(&req, &"").client_payload().unwrap();
|
|
|
|
|
|
2024-07-07 11:44:36 +02:00
|
|
|
let result = Js::render_to_string(Some(&payload));
|
2024-07-02 21:59:30 +02:00
|
|
|
|
|
|
|
|
match result {
|
|
|
|
|
Ok(html) => Html(html),
|
|
|
|
|
_ => Html("500 internal server error".to_string()),
|
|
|
|
|
}
|
|
|
|
|
}
|