quoter/src/main.rs
Untone ef78bc078b
Some checks failed
deploy / deploy (push) Failing after 3s
fmt
2024-09-23 18:17:03 +03:00

38 lines
1.1 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mod app_state;
mod auth;
mod handlers;
mod s3_utils;
mod thumbnail;
use actix_web::{middleware::Logger, web, App, HttpServer};
use app_state::AppState;
use handlers::{proxy_handler, upload_handler};
use tokio::task::spawn_blocking;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let app_state = AppState::new().await;
let app_state_clone = app_state.clone();
// Используем 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;
});
});
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(app_state.clone()))
.wrap(Logger::default())
.route("/{path:.*}", web::get().to(proxy_handler))
.route("/", web::post().to(upload_handler))
})
.bind("127.0.0.1:8080")?
.run()
.await
}