cargo fmt

This commit is contained in:
xenofem 2022-05-26 14:56:37 -04:00
parent 70e6b8bec6
commit 6bf83dcbe6

View file

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