mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-31 14:52:46 -07:00
25 lines
682 B
Rust
25 lines
682 B
Rust
|
|
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();
|
||
|
|
|
||
|
|
let result = Js::SSR.with(|ssr| ssr.borrow_mut().render_to_string(Some(&payload)));
|
||
|
|
|
||
|
|
match result {
|
||
|
|
Ok(html) => Html(html),
|
||
|
|
_ => Html("500 internal server error".to_string()),
|
||
|
|
}
|
||
|
|
}
|