feat: send && receive messages

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-05-26 05:25:37 +03:00
parent 1491669001
commit ff5512fe26
9 changed files with 281 additions and 0 deletions

28
src/main.rs Normal file
View file

@ -0,0 +1,28 @@
use std::{net::SocketAddr, sync::Arc};
use acapair_chat_api::{
routing::routing,
utils::{read_server_config, tls_config},
AppState,
};
use tokio::sync::Mutex;
#[tokio::main]
async fn main() {
println!("Hello, world!");
let server_config = read_server_config();
let tls_config = tls_config().await;
let state = AppState {
chats: Arc::new(Mutex::new(vec![])),
max_message_counter: server_config.max_message_counter,
};
let app = routing(axum::extract::State(state)).await;
let addr = SocketAddr::new(server_config.ip_address, server_config.port);
axum_server::bind_rustls(addr, tls_config)
.serve(app.into_make_service())
.await
.unwrap();
}