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

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

View file

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