aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 5f4f7a8..fcd01ab 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,9 +6,15 @@ use std::thread;
use std::time::Duration;
use actix_files::NamedFile;
+use actix_web::body::BoxBody;
+use actix_web::middleware::Compat;
use actix_web::web;
use actix_web::{http::header::ContentType, Responder};
use actix_web::{middleware, App, HttpRequest, HttpResponse};
+use actix_web_httpauth::middleware::HttpAuthentication;
+use anyhow::Result;
+use clap::{crate_version, IntoApp, Parser};
+use clap_generate::generate;
use log::{error, warn};
use qrcodegen::{QrCode, QrCodeEcc};
use yansi::{Color, Paint};
@@ -194,7 +200,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {
web::scope(inside_config.random_route.as_deref().unwrap_or(""))
.wrap(middleware::Condition::new(
!inside_config.auth.is_empty(),
- HttpAuthentication::basic(auth::handle_auth),
+ Compat::new(HttpAuthentication::basic(auth::handle_auth)),
))
.configure(|c| configure_app(c, &inside_config)),
)
@@ -292,7 +298,7 @@ fn create_tcp_listener(addr: SocketAddr) -> io::Result<TcpListener> {
fn configure_header(conf: &MiniserveConfig) -> middleware::DefaultHeaders {
conf.header.iter().flatten().fold(
middleware::DefaultHeaders::new(),
- |headers, (header_name, header_value)| headers.header(header_name, header_value),
+ |headers, (header_name, header_value)| headers.add((header_name, header_value)),
)
}
@@ -353,14 +359,14 @@ async fn favicon() -> impl Responder {
let logo = include_str!("../data/logo.svg");
HttpResponse::Ok()
.insert_header(ContentType(mime::IMAGE_SVG))
- .message_body(logo.into())
+ .body(logo)
}
async fn css() -> impl Responder {
let css = include_str!(concat!(env!("OUT_DIR"), "/style.css"));
HttpResponse::Ok()
.insert_header(ContentType(mime::TEXT_CSS))
- .message_body(css.into())
+ .message_body(BoxBody::new(css))
}
// Prints to the console two inverted QrCodes side by side.