Files
quoter/src/main.rs

38 lines
1.1 KiB
Rust
Raw Normal View History

2024-08-31 03:32:37 +03:00
mod app_state;
mod auth;
mod handlers;
mod s3_utils;
mod thumbnail;
2024-04-08 10:17:14 +03:00
2024-08-31 03:32:37 +03:00
use actix_web::{middleware::Logger, web, App, HttpServer};
use app_state::AppState;
use handlers::{proxy_handler, upload_handler};
2024-09-23 16:32:54 +03:00
use tokio::task::spawn_blocking;
2023-09-28 02:08:48 +03:00
#[actix_web::main]
async fn main() -> std::io::Result<()> {
2024-08-30 22:11:21 +03:00
let app_state = AppState::new().await;
2024-08-30 23:27:01 +03:00
let app_state_clone = app_state.clone();
2024-09-23 18:16:47 +03:00
2024-09-23 16:32:54 +03:00
// Используем spawn_blocking для работы, которая не совместима с Send
spawn_blocking(move || {
let rt = tokio::runtime::Handle::current();
rt.block_on(async move {
app_state_clone.update_filelist_from_aws().await;
app_state_clone.refresh_file_list_periodically().await;
});
2024-08-30 23:27:01 +03:00
});
2023-09-28 02:08:48 +03:00
HttpServer::new(move || {
App::new()
2024-08-30 22:11:21 +03:00
.app_data(web::Data::new(app_state.clone()))
2023-10-11 23:03:12 +03:00
.wrap(Logger::default())
2024-08-31 03:32:37 +03:00
.route("/{path:.*}", web::get().to(proxy_handler))
.route("/", web::post().to(upload_handler))
2023-09-28 02:08:48 +03:00
})
2024-08-30 21:05:51 +03:00
.bind("127.0.0.1:8080")?
2023-09-28 02:08:48 +03:00
.run()
.await
2024-09-23 18:16:47 +03:00
}