mirror of
https://github.com/speatzle/nfsense.git
synced 2025-09-13 15:19:08 +00:00
Add tokio, axum and tower-http
This commit is contained in:
parent
5782514179
commit
65bdbbbb53
3 changed files with 705 additions and 3 deletions
30
src/main.rs
30
src/main.rs
|
@ -3,13 +3,37 @@
|
|||
mod config_manager;
|
||||
mod definitions;
|
||||
|
||||
use definitions::config::Config;
|
||||
use axum::{
|
||||
response::IntoResponse,
|
||||
routing::{get, post},
|
||||
Json, Router,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
pub async fn health_checker_handler() -> impl IntoResponse {
|
||||
const MESSAGE: &str = "Hello there";
|
||||
|
||||
let json_response = serde_json::json!({
|
||||
"status": "success",
|
||||
"message": MESSAGE
|
||||
});
|
||||
|
||||
Json(json_response)
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
println!("Starting...");
|
||||
|
||||
let mut config_manager = config_manager::new_config_manager().unwrap();
|
||||
|
||||
let app = Router::new().route("/health", get(health_checker_handler));
|
||||
|
||||
println!("Server started successfully");
|
||||
axum::Server::bind(&"0.0.0.0:8000".parse().unwrap())
|
||||
.serve(app.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut tx = config_manager.start_transaction().unwrap();
|
||||
|
||||
tx.changes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue