mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-31 14:52:46 -07:00
Refactor server (#9)
* refactor: move catch_all in tuono_lib * refactor: moved server to tuono_lib * refactor: move router and server into tuono_lib * refactor: reduce exports from examples * refactor: re-organize exports * refactor: removed mode set on project builder * feat: update version to v0.3.1
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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()),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user