-
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.
Replies: 2 comments 1 reply
-
|
This was fixed in #2897 that is not released yet |
Beta Was this translation helpful? Give feedback.
-
|
Not sure how or why, but i just stumbled upon this issue: Strangely, it only happens on a single route, and i don't think i've modified much since it last worked. I'm sure i haven't touched the middlewares. I'll try to isolate the problem. EDIT: for posterity's sake, it looks like the problem was using |
Beta Was this translation helpful? Give feedback.
This was fixed in #2897 that is not released yet