JustKozrhik commited on
Commit
d3d5398
·
verified ·
1 Parent(s): 4ead3b9

Delete src/main.rs

Browse files
Files changed (1) hide show
  1. src/main.rs +0 -48
src/main.rs DELETED
@@ -1,48 +0,0 @@
1
- mod handlers;
2
- mod models;
3
- mod processor;
4
-
5
- use axum::{
6
- Router,
7
- routing::{get, post},
8
- };
9
- use std::{collections::HashMap, sync::Arc};
10
- use tokio::sync::RwLock;
11
-
12
- use handlers::{get_blockstate, get_entity, get_palette, upload_litematic};
13
- use models::SchematicData;
14
-
15
- pub struct ServerContext {
16
- pub db: RwLock<HashMap<String, Arc<SchematicData>>>,
17
- pub client: reqwest::Client,
18
- }
19
-
20
- pub type AppState = Arc<ServerContext>;
21
-
22
- #[tokio::main]
23
- async fn main() {
24
- let client = reqwest::Client::builder()
25
- .timeout(std::time::Duration::from_secs(30))
26
- .build()
27
- .unwrap();
28
-
29
- let context = Arc::new(ServerContext {
30
- db: RwLock::new(HashMap::new()),
31
- client,
32
- });
33
-
34
- let app = Router::new()
35
- .route("/upload", post(upload_litematic))
36
- .route("/get/state/:sha256/:chunk_index", get(get_blockstate))
37
- .route("/get/palette/:sha256/:chunk_index", get(get_palette))
38
- .route("/get/entity/:sha256/:chunk_index", get(get_entity))
39
- .with_state(context);
40
-
41
- let addr = format!(
42
- "0.0.0.0:{}",
43
- std::env::var("PORT").unwrap_or_else(|_| "7860".into())
44
- );
45
- let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
46
- println!("Сервер запущен на {}", addr);
47
- axum::serve(listener, app).await.unwrap();
48
- }