37 lines
722 B
Rust
37 lines
722 B
Rust
#[macro_use] extern crate async_trait;
|
|
#[macro_use] extern crate axum;
|
|
#[macro_use] extern crate log;
|
|
#[macro_use] extern crate serde;
|
|
|
|
use clap::Parser;
|
|
|
|
use std::sync::Arc;
|
|
|
|
mod cli;
|
|
mod error;
|
|
mod routes;
|
|
mod state;
|
|
mod utils;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), error::Error> {
|
|
env_logger::init();
|
|
|
|
let args = cli::Cli::parse();
|
|
let path = args.path.clone();
|
|
|
|
let _ = tokio::fs::remove_file(&path).await;
|
|
tokio::fs::create_dir_all(path.parent().unwrap())
|
|
.await
|
|
.unwrap();
|
|
|
|
let state = Arc::new(
|
|
state::AppState::new().await?
|
|
);
|
|
|
|
let app = routes::router(Some("/ssowat/".to_string()), state);
|
|
utils::socket::serve(&path, app).await?;
|
|
|
|
Ok(())
|
|
}
|