mirror of
https://git.alemi.dev/guestbook.rs.git
synced 2024-11-14 04:19:21 +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")]
|
||||
/// host to bind onto
|
||||
addr: String,
|
||||
|
||||
#[arg(long, default_value_t = false)]
|
||||
/// increase log verbosity to DEBUG level
|
||||
debug: bool,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
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 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 {
|
||||
Router::new()
|
||||
.route("/send", get(get_suggestion))
|
||||
.route("/send", post(send_suggestion_form))
|
||||
.route("/send", put(send_suggestion_json))
|
||||
.route("/api", get(get_suggestion))
|
||||
.route("/api", post(send_suggestion_form))
|
||||
.route("/api", put(send_suggestion_json))
|
||||
.with_state(Arc::new(RwLock::new(state)))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue