Add repo count to templates

This commit is contained in:
Valentin Brandl 2019-06-12 21:51:16 +02:00
parent 60dc242e5a
commit eb718990ec
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D

View File

@ -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<T> = std::result::Result<T, Error>;
@ -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()
}
}