From eb718990ecda7fa582bc54a64751601922d11b78 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Wed, 12 Jun 2019 21:51:16 +0200 Subject: [PATCH] Add repo count to templates --- src/error.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/error.rs b/src/error.rs index 3e64372..0f6edf2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,9 @@ -use crate::P500; +use crate::{ + statics::{REPO_COUNT, VERSION_INFO}, + templates, +}; use actix_web::{HttpResponse, ResponseError}; -use std::fmt; +use std::{fmt, sync::atomic::Ordering}; pub(crate) type Result = std::result::Result; @@ -33,15 +36,15 @@ impl fmt::Display for Error { impl ResponseError for Error { fn error_response(&self) -> HttpResponse { + let mut buf = Vec::new(); + templates::p500(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed)).unwrap(); HttpResponse::InternalServerError() .content_type("text/html") - .body(P500.as_slice()) + .body(buf) } fn render_response(&self) -> HttpResponse { - HttpResponse::InternalServerError() - .content_type("text/html") - .body(P500.as_slice()) + self.error_response() } }