Merge branch 'dev' of github.com:C0ffeeCode/rvault into dev

This commit is contained in:
sam 2024-04-15 13:07:27 +02:00
commit 33723601b7
2 changed files with 19 additions and 22 deletions

View file

@ -13,4 +13,6 @@ workspace = true
log = { workspace = true } log = { workspace = true }
env_logger = { workspace = true } env_logger = { workspace = true }
tokio = { workspace = true, features=["full"] } tokio = { workspace = true, features=["full"] }
axum = { workspace = true, features = ["json"] } axum = { workspace = true }
utoipa = { version = "4", features = ["axum_extras"] }
log = "0.4.21"

View file

@ -1,34 +1,29 @@
use axum::{ use axum::{extract::Request, routing::{get, post}, Router};
http::{StatusCode, Uri},
routing::get,
Router,
};
use log::warn;
use tokio::net::TcpListener;
mod auth; use log;
mod identity; use std::env;
mod secrets;
mod sys;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
env::set_var("RUST_LOG", "trace");
env_logger::init(); env_logger::init();
// build our application with a route
let app = Router::new() let app = Router::new()
.route("/", get(root)) .route("/", get(root))
.nest("/v1/auth", auth::auth_router()) .route("/v1/secret/data/foo", post(foo));
.fallback(fallback_route_unknown);
let listener = TcpListener::bind("[::]:8200").await.unwrap();
warn!("Listening on: {}", listener.local_addr().unwrap());
// run our app with hyper, listening globally on port 8200
let listener = tokio::net::TcpListener::bind("127.0.0.1:8200").await.unwrap();
axum::serve(listener, app).await.unwrap(); axum::serve(listener, app).await.unwrap();
} }
async fn fallback_route_unknown(uri: Uri, body: String) -> (StatusCode, &'static str) { async fn foo( req: Request) -> String {
log::error!("Route not found: {}, payload {}", uri, body); log::debug!("`{:?}`", req);
return String::from("RoutingTest successful");
(StatusCode::NOT_FOUND, "Route not implemented")
} }
// basic handler that responds with a static string // basic handler that responds with a static string