docs
This commit is contained in:
33
src/main.rs
33
src/main.rs
@@ -1,20 +1,27 @@
|
||||
mod app_state;
|
||||
mod auth;
|
||||
mod lookup;
|
||||
mod core;
|
||||
mod handlers;
|
||||
mod lookup;
|
||||
mod overlay;
|
||||
mod s3_utils;
|
||||
mod thumbnail;
|
||||
mod core;
|
||||
mod overlay;
|
||||
|
||||
use actix_web::{middleware::Logger, web, App, HttpServer, http::header::{self, HeaderName}};
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{
|
||||
http::header::{self, HeaderName},
|
||||
middleware::Logger,
|
||||
web, App, HttpServer,
|
||||
};
|
||||
use app_state::AppState;
|
||||
use handlers::{proxy_handler, upload_handler, root_handler};
|
||||
use log::warn;
|
||||
use tokio::task::spawn_blocking;
|
||||
use std::env;
|
||||
use env_logger;
|
||||
use handlers::{
|
||||
get_quota_handler, increase_quota_handler, proxy_handler, root_handler, set_quota_handler,
|
||||
upload_handler,
|
||||
};
|
||||
use log::warn;
|
||||
use std::env;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
@@ -38,7 +45,7 @@ async fn main() -> std::io::Result<()> {
|
||||
// Настройка CORS middleware
|
||||
let cors = Cors::default()
|
||||
.allow_any_origin() // TODO: ограничить конкретными доменами в продакшене
|
||||
.allowed_methods(vec!["GET", "POST", "OPTIONS"])
|
||||
.allowed_methods(vec!["GET", "POST", "PUT", "DELETE", "OPTIONS"])
|
||||
.allowed_headers(vec![
|
||||
header::DNT,
|
||||
header::USER_AGENT,
|
||||
@@ -49,10 +56,7 @@ async fn main() -> std::io::Result<()> {
|
||||
header::RANGE,
|
||||
header::AUTHORIZATION,
|
||||
])
|
||||
.expose_headers(vec![
|
||||
header::CONTENT_LENGTH,
|
||||
header::CONTENT_RANGE,
|
||||
])
|
||||
.expose_headers(vec![header::CONTENT_LENGTH, header::CONTENT_RANGE])
|
||||
.supports_credentials()
|
||||
.max_age(1728000); // 20 дней
|
||||
|
||||
@@ -62,6 +66,9 @@ async fn main() -> std::io::Result<()> {
|
||||
.wrap(Logger::default())
|
||||
.route("/", web::get().to(root_handler))
|
||||
.route("/", web::post().to(upload_handler))
|
||||
.route("/quota", web::get().to(get_quota_handler))
|
||||
.route("/quota/increase", web::post().to(increase_quota_handler))
|
||||
.route("/quota/set", web::post().to(set_quota_handler))
|
||||
.route("/{path:.*}", web::get().to(proxy_handler))
|
||||
})
|
||||
.bind(addr)?
|
||||
|
||||
Reference in New Issue
Block a user