Added router for routing requests
1. Duh 2. Also minor bugfix
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#![allow(unused_imports)]
|
||||
mod handlers;
|
||||
mod models;
|
||||
mod router;
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{Router, routing};
|
||||
use dotenv::dotenv;
|
||||
use models::*;
|
||||
@@ -26,12 +29,7 @@ async fn main() {
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
let app = Router::new().route("/", routing::get(root_handler));
|
||||
|
||||
let app = create_router(Arc::new(AppState { db: pool.clone() }));
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:8001").await.unwrap();
|
||||
axum::serve(listener, app).await;
|
||||
}
|
||||
|
||||
async fn root_handler() -> &'static str {
|
||||
"Hello, World"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user