minorfix6
All checks were successful
deploy / deploy (push) Successful in 1m3s

This commit is contained in:
Untone 2024-10-22 13:18:57 +03:00
parent cb12533110
commit e8955e4a5d
2 changed files with 6 additions and 4 deletions

View File

@ -8,7 +8,7 @@ use crate::handlers::serve_file::serve_file;
/// Обработчик для скачивания файла и генерации миниатюры, если она недоступна. /// Обработчик для скачивания файла и генерации миниатюры, если она недоступна.
pub async fn proxy_handler( pub async fn proxy_handler(
req: HttpRequest, _req: HttpRequest,
requested_res: web::Path<String>, requested_res: web::Path<String>,
state: web::Data<AppState>, state: web::Data<AppState>,
) -> Result<HttpResponse, actix_web::Error> { ) -> Result<HttpResponse, actix_web::Error> {

View File

@ -7,6 +7,7 @@ mod thumbnail;
use actix_web::{middleware::Logger, web, App, HttpServer}; use actix_web::{middleware::Logger, web, App, HttpServer};
use app_state::AppState; use app_state::AppState;
use handlers::{proxy_handler, upload_handler}; use handlers::{proxy_handler, upload_handler};
use log::info;
use tokio::task::spawn_blocking; use tokio::task::spawn_blocking;
use std::env; use std::env;
use env_logger; use env_logger;
@ -14,8 +15,11 @@ use env_logger;
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
env_logger::init(); env_logger::init();
let app_state = AppState::new().await; info!("Started");
let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let addr = format!("0.0.0.0:{}", port);
let app_state = AppState::new().await;
let app_state_clone = app_state.clone(); let app_state_clone = app_state.clone();
// Используем spawn_blocking для работы, которая не совместима с Send // Используем spawn_blocking для работы, которая не совместима с Send
@ -26,8 +30,6 @@ async fn main() -> std::io::Result<()> {
}); });
}); });
let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let addr = format!("0.0.0.0:{}", port);
HttpServer::new(move || { HttpServer::new(move || {
App::new() App::new()
.app_data(web::Data::new(app_state.clone())) .app_data(web::Data::new(app_state.clone()))