| 153 | } |
| 154 | |
| 155 | async fn not_found(data: web::Data<AppState>, request: HttpRequest) -> Result<HttpResponse, Error> { |
| 156 | let mut ctx = tera::Context::new(); |
| 157 | ctx.insert("uri", request.uri().path()); |
| 158 | |
| 159 | let template = &data.templates; |
| 160 | let body = template |
| 161 | .render("error/404.html.tera", &ctx) |
| 162 | .map_err(|_| error::ErrorInternalServerError("Template error"))?; |
| 163 | |
| 164 | Ok(HttpResponse::Ok().content_type("text/html").body(body)) |
| 165 | } |
| 166 | |
| 167 | #[actix_web::main] |
| 168 | async fn start() -> std::io::Result<()> { |