Files
backend-local/src/main.rs

45 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 general;
#[cfg(local)]
mod local;
use axum::{
extract::DefaultBodyLimit,
routing::get,
Router,
};
use tower_http::cors::CorsLayer;
use tracing::info;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
.with_target(true)
.with_thread_ids(true)
.with_file(true)
.with_line_number(true)
.init();
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
.layer(DefaultBodyLimit::max(50 * 1024 * 1024))
.layer(CorsLayer::permissive());
info!("🖨️ Print API запущен на http://0.0.0.0:3000");
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000")
.await
.expect("Не удалось забиндить порт 3000");
axum::serve(listener, app)
.await
.expect("Ошибка сервера");
}