2026-09-19 15:10:01 +03:00
|
|
|
|
mod general;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(local)]
|
|
|
|
|
|
mod local;
|
|
|
|
|
|
|
2026-09-05 01:26:17 +03:00
|
|
|
|
use axum::{
|
2026-09-19 15:10:01 +03:00
|
|
|
|
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-17 16:03:03 +03:00
|
|
|
|
|
2026-09-05 01:26:17 +03:00
|
|
|
|
#[tokio::main]
|
|
|
|
|
|
async fn main() {
|
2026-09-07 13:25:13 +03:00
|
|
|
|
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()
|
2026-09-19 15:10:01 +03:00
|
|
|
|
.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))
|
2026-09-19 15:10:01 +03:00
|
|
|
|
.layer(CorsLayer::permissive());
|
2026-09-05 01:26:17 +03:00
|
|
|
|
|
2026-09-07 13:25:13 +03:00
|
|
|
|
info!("🖨️ Print API запущен на http://0.0.0.0:3000");
|
2026-09-19 15:10:01 +03:00
|
|
|
|
|
2026-09-05 01:26:17 +03:00
|
|
|
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000")
|
|
|
|
|
|
.await
|
2026-09-07 13:25:13 +03:00
|
|
|
|
.expect("Не удалось забиндить порт 3000");
|
|
|
|
|
|
|
2026-09-19 15:10:01 +03:00
|
|
|
|
axum::serve(listener, app)
|
|
|
|
|
|
.await
|
|
|
|
|
|
.expect("Ошибка сервера");
|
2026-09-18 01:44:06 +03:00
|
|
|
|
}
|