Add tokio, axum and tower-http

This commit is contained in:
Samuel Lorch 2023-10-22 02:09:40 +02:00
parent 5782514179
commit 65bdbbbb53
3 changed files with 705 additions and 3 deletions

View file

@ -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