Update index.rs

This commit is contained in:
Adrian Woźniak 2023-07-28 21:58:54 +02:00
parent 4f01634b0e
commit 27b6889a8b

View File

@ -29,14 +29,22 @@ pub async fn index(session: Session, data: web::Data<ActixAdmin>) -> Result<Http
let body = actix_admin.tera
.render("index.html", &ctx)
.map_err(|_| error::ErrorInternalServerError("Template error"))?;
.map_err(|e| {
#[cfg(enable_tracing)]
tracing::warn!("{}", e);
error::ErrorInternalServerError("Template error")
})?;
Ok(HttpResponse::Ok().content_type("text/html").body(body))
}
pub async fn not_found(data: web::Data<ActixAdmin>) -> Result<HttpResponse, Error> {
let body = data.get_ref().tera
.render("not_found.html", &Context::new())
.map_err(|_| error::ErrorInternalServerError("Template error"))?;
.map_err(|e| {
#[cfg(enable_tracing)]
tracing::warn!("{}", e);
error::ErrorInternalServerError("Template error")
})?;
Ok(HttpResponse::NotFound().content_type("text/html").body(body))
}