use axum::{
body::Body,
extract::State,
http::Request,
response::{IntoResponse, Response},
};
use dioxus::server::{FullstackState, ServeConfig};
use hyle::FormErrors;
#[derive(Clone, Copy)]
pub struct HyleRenderer;
impl HyleRenderer {
pub async fn render_with_errors(
self,
fullstack_state: FullstackState,
uri: &str,
errors: FormErrors,
) -> Response {
let error_state = fullstack_state
.with_config(ServeConfig::new().context_provider(move || errors.clone()));
let req = Request::builder()
.method("GET")
.uri(uri)
.body(Body::empty())
.unwrap();
FullstackState::render_handler(State(error_state), req)
.await
.into_response()
}
}