mirror of
https://git.alemi.dev/guestbook.rs.git
synced 2024-12-19 02:54:52 +01:00
fix: renamed routes to api, added debug logging
This commit is contained in:
parent
b28e8fc394
commit
e21be6b917
2 changed files with 12 additions and 5 deletions
11
src/main.rs
11
src/main.rs
|
@ -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"));
|
||||||
|
|
|
@ -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)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue