Files
backend-local/src/main.rs

45 lines
1.1 KiB
Rust
Raw Normal View History

mod general;
#[cfg(local)]
mod local;
2026-09-05 01:26:17 +03:00
use axum::{
extract::DefaultBodyLimit,
routing::get,
Router,
2026-09-05 01:26:17 +03:00
};
use tower_http::cors::CorsLayer;
2026-09-18 20:25:02 +03:00
use tracing::info;
2026-09-05 01:26:17 +03:00
#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
.with_target(true)
.with_thread_ids(true)
.with_file(true)
.with_line_number(true)
.init();
2026-09-05 01:26:17 +03:00
let app = Router::new()
.route("/version", get(general::version::get_version))
.route("/is_local", get(general::is_local::is_local))
.route("/is_server", get(general::is_server::is_server));
#[cfg(local)]
let app = app.merge(local::routes());
let app = app
2026-09-18 20:25:02 +03:00
.layer(DefaultBodyLimit::max(50 * 1024 * 1024))
.layer(CorsLayer::permissive());
2026-09-05 01:26:17 +03:00
info!("🖨️ Print API запущен на http://0.0.0.0:3000");
2026-09-05 01:26:17 +03:00
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000")
.await
.expect("Не удалось забиндить порт 3000");
axum::serve(listener, app)
.await
.expect("Ошибка сервера");
2026-09-18 01:44:06 +03:00
}