fix: renamed routes to api, added debug logging

This commit is contained in:
əlemi 2023-12-23 01:26:31 +01:00
parent b28e8fc394
commit e21be6b917
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 12 additions and 5 deletions

View file

@ -19,14 +19,21 @@ struct CliArgs {
#[arg(long, short, default_value = "127.0.0.1:37812")] #[arg(long, short, default_value = "127.0.0.1:37812")]
/// host to bind onto /// host to bind onto
addr: String, addr: String,
#[arg(long, default_value_t = false)]
/// increase log verbosity to DEBUG level
debug: bool,
} }
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
tracing_subscriber::fmt::init();
let args = CliArgs::parse(); let args = CliArgs::parse();
tracing_subscriber::fmt::fmt()
.with_max_level(if args.debug { tracing::Level::DEBUG } else { tracing::Level::INFO })
.pretty()
.finish();
let addr : SocketAddr = args.addr.parse().expect("invalid host provided"); let addr : SocketAddr = args.addr.parse().expect("invalid host provided");
let storage = Box::new(JsonFileStorageStrategy::new("./storage.json")); let storage = Box::new(JsonFileStorageStrategy::new("./storage.json"));

View file

@ -7,9 +7,9 @@ use crate::{notifications::NotificationProcessor, model::{Suggestion, Acknowledg
pub fn create_router_with_app_routes(state: Context) -> Router { pub fn create_router_with_app_routes(state: Context) -> Router {
Router::new() Router::new()
.route("/send", get(get_suggestion)) .route("/api", get(get_suggestion))
.route("/send", post(send_suggestion_form)) .route("/api", post(send_suggestion_form))
.route("/send", put(send_suggestion_json)) .route("/api", put(send_suggestion_json))
.with_state(Arc::new(RwLock::new(state))) .with_state(Arc::new(RwLock::new(state)))
} }