cargo fmt

main
xenofem 2022-05-26 14:56:37 -04:00
parent 70e6b8bec6
commit 6bf83dcbe6
1 changed files with 22 additions and 6 deletions

View File

@ -7,8 +7,8 @@ mod zip;
use std::{fmt::Debug, path::PathBuf, str::FromStr};
use actix_web::{
error::InternalError, get, middleware::Logger, post, web, App, HttpRequest,
HttpResponse, HttpServer, Responder,
error::InternalError, get, middleware::Logger, post, web, App, HttpRequest, HttpResponse,
HttpServer, Responder,
};
use actix_web_actors::ws;
use askama::Template;
@ -52,11 +52,19 @@ pub fn log_auth_failure(ip_addr: &str) {
#[derive(Template)]
#[template(path = "index.html")]
struct IndexPage<'a> { cachebuster: &'a str }
struct IndexPage<'a> {
cachebuster: &'a str,
}
#[get("/")]
async fn index(data: web::Data<AppState>) -> impl Responder {
HttpResponse::Ok().body(IndexPage { cachebuster: &data.config.cachebuster }.render().unwrap())
HttpResponse::Ok().body(
IndexPage {
cachebuster: &data.config.cachebuster,
}
.render()
.unwrap(),
)
}
#[derive(Deserialize)]
@ -168,7 +176,9 @@ async fn download_info(
#[derive(Template)]
#[template(path = "404.html")]
struct NotFoundPage<'a> { cachebuster: &'a str }
struct NotFoundPage<'a> {
cachebuster: &'a str,
}
fn not_found<T>(req: HttpRequest, data: web::Data<AppState>, report: bool) -> actix_web::Result<T> {
if report {
@ -177,7 +187,13 @@ fn not_found<T>(req: HttpRequest, data: web::Data<AppState>, report: bool) -> ac
}
Err(InternalError::from_response(
"Download not found",
HttpResponse::NotFound().body(NotFoundPage { cachebuster: &data.config.cachebuster }.render().unwrap()),
HttpResponse::NotFound().body(
NotFoundPage {
cachebuster: &data.config.cachebuster,
}
.render()
.unwrap(),
),
)
.into())
}