-
Summaryim trying to make a middleware that wraps the body in a template. i tried some solutions from stackoverflow and github issues but i cant get it to work properly. pub async fn inject_base(request: Request, next: Next) -> Response {
let response = next.run(request).await;
let inject = !response.headers().contains_key("HX-Request");
let (parts, body) = response.into_parts();
let body = body::to_bytes(body, usize::MAX).await.unwrap();
let body = String::from_utf8(body.to_vec()).unwrap();
let body = Body::from(if inject {
BaseTemplate {
title: "",
style: "",
body,
}.to_string()
} else {
body
});
Response::from_parts(parts, body)
} the error im getting
axum version0.7.7 |
Beta Was this translation helpful? Give feedback.
Answered by
yanns
Oct 21, 2024
Replies: 1 comment
-
This was fixed in #2897 that is not released yet |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
piquu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was fixed in #2897 that is not released yet